· 10 years ago · Jul 28, 2016, 09:24 AM
1using Occfinance.Code;
2using Occfinance.Models;
3using Occfinance_Data;
4using System;
5using System.Collections.Generic;
6using System.Data;
7using System.Data.SqlClient;
8using System.IO;
9using System.Linq;
10using System.Web;
11using System.Web.Mvc;
12namespace Occfinance.Controllers
13{
14 [App_Start.SessionTimeOutActionFilter]
15 public class SubscribeUserController : Controller
16 {
17 #region [Declarations]
18 Q_settings QSettings = new Q_settings();
19 Q_Client QClient = new Q_Client();
20 #endregion [Declarations]
21
22 #region [Manage Subscribers]
23
24 /// <summary>
25 /// Show subscribed user list.
26 /// </summary>
27 /// <returns></returns>
28 public ActionResult Index()
29 {
30 if (Session["LoggedInUserAccountId"] != null)
31 {
32 int userId = Convert.ToInt32(Session["LoggedInUserAccountId"]?? 0 );
33 int loggedinuser = Convert.ToInt32(Session["LoggedInUserId"] ?? 0);
34 DataTable brokersDt = QSettings.GetBrokers(userId);
35
36 //get brokers
37 var brokers = SqlHelper.CreateListFromTable<BrokerList>(brokersDt).Select(a => new SelectListItem { Text = a.BrokerName, Value = a.BrokerID.ToString() }).ToList();
38 brokers.Insert(0, new SelectListItem { Text = "-- Please Select --", Value = "", Selected = true });
39 @ViewBag.Brokers = brokers;
40
41 //get clients
42 var clients = QClient.FindClients(userId, loggedinuser).OrderBy(c => c.companyname).Select(c => new SelectListItem
43 {
44 Text = c.companyname,
45 Value = c.clientid.ToString()
46 }).ToList();
47 clients.Insert(0, new SelectListItem { Text = "-- Please Select --", Value = "", Selected = true });
48 @ViewBag.Clients = clients;
49 }
50 return View();
51 }
52
53 /// <summary>
54 /// Show subscribed user list.
55 /// </summary>
56 /// <param name="pageNo"></param>
57 /// <param name="brokers"></param>
58 /// <param name="clients"></param>
59 /// <param name="username"></param>
60 /// <param name="isSusbcribed"></param>
61 /// <returns></returns>
62 [HttpPost]
63 public ActionResult Index(int pageNo=1, string brokers="", string clients="", string username="", bool isSusbcribed=false)
64 {
65 int userId = Convert.ToInt32(Session["LoggedInUserAccountId"] ?? 0);
66 pageNo = pageNo == 0 ? 1 : pageNo;
67
68 if (Session["LoggedInUserAccountId"] != null)
69 {
70 int loggedinuser = Convert.ToInt32(Session["LoggedInUserId"] ?? 0);
71 DataTable brokersDt = QSettings.GetBrokers(userId);
72
73 //get brokers
74 var brokerlst = SqlHelper.CreateListFromTable<BrokerList>(brokersDt).Select(a => new SelectListItem { Text = a.BrokerName, Value = a.BrokerID.ToString() }).ToList();
75 brokerlst.Insert(0, new SelectListItem { Text = "-- Please Select --", Value = "", Selected = true });
76 @ViewBag.Brokers = brokerlst;
77
78 //get clients
79 var clientslst = QClient.FindClients(userId, loggedinuser).OrderBy(c => c.companyname).Select(c => new SelectListItem
80 {
81 Text = c.companyname,
82 Value = c.clientid.ToString()
83 }).ToList();
84 clientslst.Insert(0, new SelectListItem { Text = "-- Please Select --", Value = "", Selected = true });
85 @ViewBag.Clients = clientslst;
86 }
87
88 if (Request.IsAjaxRequest())
89 {
90 List<UsersDetail> model = model = GetUnsubscribeUser(userId, pageNo, brokers, clients, username, isSusbcribed);
91
92 if (model.Count == 0)
93 {
94 @ViewBag.pageNo = 1;
95 model = GetUnsubscribeUser(userId, 1, brokers, clients, username, isSusbcribed);
96 }
97 else
98 {
99 @ViewBag.pageNo = pageNo;
100 }
101
102 string view = RenderPartialViewToUTFString(ControllerContext, ViewData, TempData, "_PartialUserList", model);
103 return Content(view, "text/html");
104 }
105 else
106 {
107 return View(GetUnsubscribeUser(userId, pageNo, brokers, clients, username, isSusbcribed));
108 }
109 }
110
111 /// <summary>
112 /// Add subscribers.
113 /// </summary>
114 /// <param name="contactid"></param>
115 /// <returns></returns>
116 [HttpPost]
117 public bool AddSubscriber(int contactid)
118 {
119
120 bool result = false;
121 if (HttpContext.Request.IsAjaxRequest())
122 {
123 try
124 {
125 WebUtility.UnsubscribeEmail(contactid, 1 /*insert*/);
126 result = true;
127 }
128 catch (Exception)
129 {
130
131 }
132 return result;
133 }
134 else
135 {
136 return result;
137 }
138
139 }
140
141 #endregion [Manage Subscribers]
142
143 #region [Delete subscriber]
144
145 /// <summary>
146 /// Delete subscriber from subscribed list.
147 /// </summary>
148 /// <param name="contactid"></param>
149 /// <returns></returns>
150 [HttpPost]
151 public bool Delete(int contactid)
152 {
153 if (HttpContext.Request.IsAjaxRequest())
154 {
155 return DeleteSubscriber(contactid);
156 }
157 else
158 {
159 return false;
160 }
161 }
162
163 /// <summary>
164 /// Delete subscriber from subscribed list.
165 /// </summary>
166 /// <param name="contactid"></param>
167 /// <returns></returns>
168 public bool DeleteSubscriber(long contactid)
169 {
170 bool result = false;
171 try
172 {
173 if (contactid != null)
174 {
175 SqlParameter[] Param = new SqlParameter[1];
176 Param[0] = new SqlParameter("@contactid", contactid);
177 string _procedurename = "DeleteSubscribedUser";
178 SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, _procedurename, Param);
179 result = true;
180 }
181 return result;
182 }
183 catch (Exception)
184 {
185 return result;
186 }
187 }
188
189 #endregion [Delete subscriber]
190
191 #region [Get Unsubscribe Users]
192
193 /// <summary>
194 /// Get unsubscribe user
195 /// </summary>
196 /// <param name="userId"></param>
197 /// <param name="pageNo"></param>
198 /// <param name="brokers"></param>
199 /// <param name="clients"></param>
200 /// <param name="username"></param>
201 /// <param name="isSusbcribed"></param>
202 /// <returns></returns>
203 [NonAction]
204 public List<UsersDetail> GetUnsubscribeUser(int userId,int pageNo, string brokers, string clients, string username,bool isSusbcribed)
205 {
206 DataTable subscriberDt = QSettings.GetUSerSubscription(userId,pageNo, 10, brokers, clients, username, isSusbcribed);
207 List<UsersDetail> uselist = SqlHelper.CreateListFromTable<UsersDetail>(subscriberDt).ToList();
208 return uselist?? new List<UsersDetail>();
209 }
210
211 /// <summary>
212 /// Render partial view to utf string.
213 /// </summary>
214 /// <param name="controllerContextontrollerContext"></param>
215 /// <param name="viewData"></param>
216 /// <param name="tempData"></param>
217 /// <param name="viewName"></param>
218 /// <param name="myModel"></param>
219 /// <returns></returns>
220 public string RenderPartialViewToUTFString(ControllerContext controllerContextontrollerContext,
221ViewDataDictionary viewData, TempDataDictionary tempData, string viewName, object myModel)
222 {
223 if (string.IsNullOrEmpty(viewName))
224 viewName = controllerContextontrollerContext.RouteData.GetRequiredString("action");
225
226 viewData.Model = myModel;
227
228 using (var sw = new StringWriter())
229 {
230 var viewResult = ViewEngines.Engines.FindPartialView(controllerContextontrollerContext, viewName);
231 var viewContext = new ViewContext(controllerContextontrollerContext, viewResult.View, viewData, tempData, sw);
232 viewResult.View.Render(viewContext, sw);
233
234 var s = sw.GetStringBuilder().ToString();
235 return s;
236 }
237 }
238
239 #endregion [Get Unsubscribe Users]
240 }
241}
242
243
244
245using System;
246using System.Collections.Generic;
247using System.IO;
248using System.Linq;
249using System.Net;
250using System.Net.Http;
251using System.Threading.Tasks;
252using System.Web;
253using System.Web.Http;
254
255namespace MultipleFileUpload.Controllers
256{
257 public class UploadBrokerController : ApiController
258 {
259 /// <summary>
260 /// Upload file.
261 /// </summary>
262 /// <returns></returns>
263 [HttpPost]
264 public async Task<object> UploadFile()
265 {
266 string subPath = System.Configuration.ConfigurationManager.AppSettings["BrokerImages"] ?? "~/Content/BrokerImages";
267 bool isExists = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(subPath));
268
269 if (!isExists)
270 System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(subPath));
271
272 NamedMultipartFormDataStreamProviderBrokerController streamProvider = new NamedMultipartFormDataStreamProviderBrokerController(
273 HttpContext.Current.Server.MapPath(subPath));
274 await Request.Content.ReadAsMultipartAsync(streamProvider);
275 return new
276{
277 FileNames = streamProvider.FileData.Select(entry => entry.LocalFileName)
278};
279 }
280 }
281}
282
283
284using System;
285using System.Collections.Generic;
286using System.IO;
287using System.Linq;
288using System.Net;
289using System.Net.Http;
290using System.Threading.Tasks;
291using System.Web;
292using System.Web.Http;
293
294namespace MultipleFileUpload.Controllers
295{
296 public class UploadController : ApiController
297 {
298 /// <summary>
299 /// Upload files.
300 /// </summary>
301 /// <returns></returns>
302 [HttpPost]
303 public async Task<object> UploadFile()
304 {
305 string _individualFolder = "IssueScreenshots_" + Convert.ToString(Guid.NewGuid());
306 if (!Request.Content.IsMimeMultipartContent("form-data"))
307 {
308 throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
309 }
310 string subPath = System.Configuration.ConfigurationManager.AppSettings["MailAttachment"] + _individualFolder;
311 bool isExists = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(subPath));
312 if (!isExists)
313 System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(subPath));
314 NamedMultipartFormDataStreamProvider streamProvider = new NamedMultipartFormDataStreamProvider(
315 HttpContext.Current.Server.MapPath(subPath));
316
317 await Request.Content.ReadAsMultipartAsync(streamProvider);
318 return new
319 {
320 FileNames = streamProvider.FileData.Select(entry => entry.LocalFileName),
321 IndividualFolderName = _individualFolder
322 };
323 }
324 }
325}
326
327
328using System;
329using System.Collections.Generic;
330using System.IO;
331using System.Linq;
332using System.Net.Http;
333using System.Web;
334
335namespace MultipleFileUpload.Controllers
336{
337 public class NamedMultipartFormDataStreamProviderBrokerController : MultipartFormDataStreamProvider
338 {
339 public NamedMultipartFormDataStreamProviderBrokerController(string fileName)
340 : base(fileName)
341 {
342 }
343
344 public override string GetLocalFileName(System.Net.Http.Headers.HttpContentHeaders headers)
345 {
346 string fileName = base.GetLocalFileName(headers);
347 if (!string.IsNullOrEmpty(headers.ContentDisposition.FileName))
348 {
349 fileName = headers.ContentDisposition.FileName;
350 }
351 if (fileName.StartsWith("\"") && fileName.EndsWith("\""))
352 {
353 fileName = fileName.Trim('"');
354 }
355 if (fileName.Contains(@"/") || fileName.Contains(@"\"))
356 {
357 fileName = Path.GetFileName(fileName);
358 }
359
360 string ext = Path.GetExtension(fileName);
361 fileName = Guid.NewGuid() + ext;
362 return fileName;
363 }
364
365 }
366}
367
368
369
370using System;
371using System.Collections.Generic;
372using System.IO;
373using System.Linq;
374using System.Net.Http;
375using System.Web;
376
377namespace MultipleFileUpload.Controllers
378{
379 public class NamedMultipartFormDataStreamProvider : MultipartFormDataStreamProvider
380 {
381 public NamedMultipartFormDataStreamProvider(string fileName):base(fileName)
382 {
383 }
384
385 public override string GetLocalFileName(System.Net.Http.Headers.HttpContentHeaders headers)
386 {
387 string fileName = base.GetLocalFileName(headers);
388 if (!string.IsNullOrEmpty(headers.ContentDisposition.FileName))
389 {
390 fileName = headers.ContentDisposition.FileName;
391 }
392 if (fileName.StartsWith("\"") && fileName.EndsWith("\""))
393 {
394 fileName = fileName.Trim('"');
395 }
396 if (fileName.Contains(@"/") || fileName.Contains(@"\"))
397 {
398 fileName = Path.GetFileName(fileName);
399 }
400 return fileName;
401 }
402 }
403}
404
405
406
407
408
409
410
411using Code;
412using MailChimp;
413using Mandrill;
414using Occfinance.Code;
415using Occfinance.Common;
416using Occfinance.Models;
417using Occfinance_Data;
418using System;
419using System.Collections.Generic;
420using System.Data;
421using System.Data.SqlClient;
422using System.Globalization;
423using System.Linq;
424using System.Text;
425using System.Web;
426using System.Web.Mvc;
427using Codes;
428using System.IO;
429using System.Configuration;
430using Occfinance.Helpers;
431namespace Occfinance.Controllers
432{
433 public class HomeController : Controller
434 {
435 #region [Declarations]
436 public db_occfinance_5572Entities ctx = new db_occfinance_5572Entities();
437 Q_User Quser = new Q_User();
438 Q_Client Qclient = new Q_Client();
439 Q_settings QSetting = new Q_settings();
440 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
441 #endregion [Declarations]
442
443 public ActionResult privacy_policy()
444 {
445 return View();
446 }
447 public ActionResult terms_and_conditions()
448 {
449 return View();
450 }
451 public ActionResult testimonials()
452 {
453 return View();
454 }
455
456 /// <summary>
457 /// Send email
458 /// </summary>
459 /// <param name="enqname"></param>
460 /// <param name="enqemail"></param>
461 /// <param name="enqtel"></param>
462 /// <param name="companyname"></param>
463 /// <returns></returns>
464 public ActionResult Sendmail(string enqname, string enqemail, string enqtel, string companyname)
465 {
466 int status = 0;
467 try
468 {
469 var supportemail = Convert.ToString(ConfigurationManager.AppSettings["SupportEmail"] ?? "team@occfinance.com");
470 var ccmail = Convert.ToString(ConfigurationManager.AppSettings["CCEmail"] ?? "crispy50@hotmail.com");
471 var bccemail = Convert.ToString(ConfigurationManager.AppSettings["BCCEmail"] ?? "team@occfinance.com");
472
473 string body = "Hi, <br /><br />";
474 body += "I am interested to your products.<br />";
475 body += "Please let me know accordingly.<br /><br />";
476 body += "Below is my contact details.<br /><br />";
477 body += "Name: " + enqname + "<br />";
478 body += "Email: " + enqemail + "<br />";
479 body += "Telephone: " + enqtel + "<br />";
480 body += "Comapany Name: " + companyname + "<br /><br />";
481 body += "Regards: <br />";
482 body += enqname;
483
484 //System.Threading.Tasks.Task.Run(() =>
485 //{
486 // MailHelper.SendMailMessage(supportemail, bccemail, ccmail, "New lead from website", body);
487 //});
488
489
490 List<ManDRILLModel> _mandrillOBJ = new List<ManDRILLModel>();
491
492 var _mailDrilEmails = new List<EmailAddress>();
493 EmailAddress objEm = new EmailAddress();
494 objEm.email = supportemail;
495 objEm.name = "";
496 _mailDrilEmails.Add(objEm);
497
498 objEm.email = ccmail;
499 objEm.name = "";
500 objEm.type = "cc";
501 _mailDrilEmails.Add(objEm);
502
503
504 objEm.email = bccemail;
505 objEm.name = "";
506 objEm.type = "bcc";
507 _mailDrilEmails.Add(objEm);
508
509 //Man DRILL ********************************************************************
510
511 var domain = "occfinance.com";
512 EmailMessage message = new EmailMessage();
513 var _mandrillMessage = new List<EmailMessage>();
514
515 message.to = _mailDrilEmails;
516 message.html = body;
517 message.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
518 message.from_name = "OCC";
519 message.subject = "New lead from website";
520 message.inline_css = true;
521 message.signing_domain = domain;
522 message.AddHeader("X-MC-SigningDomain", domain);
523 message.AddHeader("X-MC-TrackingDomain", domain);
524 _mandrillMessage.Add(message);
525
526 //********************************************************************************
527
528 // Manage The ManDRILLModel - 25-07-2014
529
530 var objMAN = new ManDRILLModel();
531 objMAN.contactId = 0;
532 objMAN.financeid = 0;
533 objMAN.mailcontent = body;
534 objMAN.MandrillMSG = message;
535 objMAN.IsAppContact = false;
536
537 objMAN.notemsg = "";
538
539 _mandrillOBJ.Add(objMAN);
540
541 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
542 WebUtility.SendMailViaManDRILL(_mandrillOBJ, userId);
543
544
545 string bodyuser = "Hi , " + enqname + " <br /><br />";
546 bodyuser += "Thanks for your interest to our products.<br />";
547 bodyuser += "We will contact you shortly.<br /><br />";
548 bodyuser += "Regards: <br />";
549 bodyuser += "Administrator<br />";
550 bodyuser += "OCC Finance<br />";
551
552 //System.Threading.Tasks.Task.Run(() =>
553 //{
554 // MailHelper.SendMailMessage(enqemail, bccemail, ccmail, "Greetings From OCC Finance", bodyuser);
555 //});
556
557 List<ManDRILLModel> mandrillObj1 = new List<ManDRILLModel>();
558
559 var _mailDrilEmails1 = new List<EmailAddress>();
560 EmailAddress objEm1 = new EmailAddress();
561 objEm1.email = enqemail;
562 objEm1.name = "";
563 _mailDrilEmails1.Add(objEm1);
564
565 objEm1.email = ccmail;
566 objEm1.name = "";
567 objEm1.type = "cc";
568 _mailDrilEmails1.Add(objEm1);
569
570
571 objEm1.email = bccemail;
572 objEm1.name = "";
573 objEm1.type = "bcc";
574 _mailDrilEmails1.Add(objEm1);
575
576 //Man DRILL ********************************************************************
577
578 var domain1 = "occfinance.com";
579 EmailMessage message1 = new EmailMessage();
580 var _mandrillMessage1 = new List<EmailMessage>();
581
582 message1.to = _mailDrilEmails1;
583 message1.html = bodyuser;
584 message1.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
585 message1.from_name = "OCC";
586 message1.subject = "Greetings From OCC Finance";
587 message1.inline_css = true;
588 message1.signing_domain = domain1;
589 message1.AddHeader("X-MC-SigningDomain", domain1);
590 message1.AddHeader("X-MC-TrackingDomain", domain1);
591 _mandrillMessage1.Add(message1);
592
593 //********************************************************************************
594
595 // Manage The ManDRILLModel - 25-07-2014
596
597 var objMAN1 = new ManDRILLModel();
598 objMAN1.contactId = 0;
599 objMAN1.financeid = 0;
600 objMAN1.mailcontent = bodyuser;
601 objMAN1.MandrillMSG = message1;
602 objMAN1.IsAppContact = false;
603
604 objMAN1.notemsg = "";
605
606 mandrillObj1.Add(objMAN1);
607
608
609 WebUtility.SendMailViaManDRILL(mandrillObj1, userId);
610
611 status = 1;
612
613 }
614 catch(Exception ex)
615 {
616 Helper.ErrorLog(ex.InnerException, "HomeController", "Sendmail", ex.Message);
617 }
618 return Json(status, JsonRequestBehavior.AllowGet);
619 }
620
621 /// <summary>
622 /// Send activation email
623 /// </summary>
624 /// <param name="UserId"></param>
625 /// <param name="Subject"></param>
626 /// <param name="Name"></param>
627 /// <param name="Content"></param>
628 /// <param name="UserName"></param>
629 /// <param name="Password"></param>
630 /// <returns></returns>
631 public ActionResult SendActivationmail(int UserId, string Subject, string Name, string Content, string UserName, string Password)
632 {
633 bool _chkmail = false;
634 int status = 0;
635 if (UserId > 0)
636 {
637
638 status = QSetting.ActivateClient(UserId);
639
640 if (status > 0)
641 {
642 var supportemail = Convert.ToString(ConfigurationManager.AppSettings["SupportEmail"] ?? "team@occfinance.com");
643 var ccmail = Convert.ToString(ConfigurationManager.AppSettings["CCEmail"] ?? "crispy50@hotmail.com");
644 var bccemail = Convert.ToString(ConfigurationManager.AppSettings["BCCEmail"] ?? "team@occfinance.com");
645
646 string body = "Hi , " + Name + " <br /><br /><br />";
647 body += "<br />";
648 body += Content + "<br /><br /><br />";
649 body += "User Name: " + UserName + " <br /><br />";
650 body += "Password: " + Password + " <br /><br />";
651 body += "Regards: <br /><br />";
652 body += "Administrator<br /><br />";
653 body += "OCC Finance<br /><br />";
654
655
656 var _secureURL = Convert.ToString(ConfigurationManager.AppSettings["SecureURL"] ?? "");
657 var _contentURL = Convert.ToString(ConfigurationManager.AppSettings["ContentURL"] ?? "");
658
659 var AppTrackImg = _secureURL + "/Content/images/" + Convert.ToString("apptrack.jpg");
660 var AppTrackLogo = _secureURL + "/Content/images/" + Convert.ToString(Session["SiteLogo"] ?? "logo_6569.jpg");
661 var FooterCopyRight = "© 2014 Finance Technology Ltd. Registered trademarks IntelliCalc®, AppTrack®. All rights reserved";
662 var SupportFooter = "Contact Us on: 0845 521 5153, Specialising in financial technologies & solutions";
663 var _mailTemplate = Codes.Extensions.Mailtemplates(AppTrackImg, AppTrackLogo, body, FooterCopyRight, SupportFooter, _contentURL);
664
665 //System.Threading.Tasks.Task.Run(() =>
666 //{
667 // _chkmail = MailHelper.SendMailMessage(UserName, "", "", "Your Apptrack Credential", _mailTemplate);
668 //});
669
670
671 List<ManDRILLModel> _mandrillOBJ = new List<ManDRILLModel>();
672
673 var _mailDrilEmails = new List<EmailAddress>();
674 EmailAddress objEm = new EmailAddress();
675 objEm.email = UserName;
676 objEm.name = Name;
677 _mailDrilEmails.Add(objEm);
678
679 //Man DRILL ********************************************************************
680
681 var domain = "occfinance.com";
682 EmailMessage message = new EmailMessage();
683 var _mandrillMessage = new List<EmailMessage>();
684
685 message.to = _mailDrilEmails;
686 message.html = _mailTemplate;
687 message.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
688 message.from_name = "OCC";
689 message.subject = "Your Apptrack Credential";
690 message.inline_css = true;
691 message.signing_domain = domain;
692 message.AddHeader("X-MC-SigningDomain", domain);
693 message.AddHeader("X-MC-TrackingDomain", domain);
694 _mandrillMessage.Add(message);
695
696 //********************************************************************************
697
698 // Manage The ManDRILLModel - 25-07-2014
699
700 var objMAN = new ManDRILLModel();
701 objMAN.contactId = 0;
702 objMAN.financeid = 0;
703 objMAN.mailcontent = _mailTemplate;
704 objMAN.MandrillMSG = message;
705 objMAN.IsAppContact = false;
706
707 objMAN.notemsg = "";
708
709 _mandrillOBJ.Add(objMAN);
710
711 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
712 WebUtility.SendMailViaManDRILL(_mandrillOBJ, userId);
713
714
715 }
716 }
717 return Json(status, JsonRequestBehavior.AllowGet);
718 }
719
720 /// <summary>
721 /// Send registration email
722 /// </summary>
723 /// <param name="regenqname"></param>
724 /// <param name="regenqemail"></param>
725 /// <param name="regenqtel"></param>
726 /// <param name="regcompanyname"></param>
727 /// <returns></returns>
728 public ActionResult Registration(string regenqname, string regenqemail, string regenqtel, string regcompanyname)
729 {
730 int status = 0;
731 try
732 {
733 status = QSetting.Registration(regcompanyname, regenqname, regenqtel, regenqemail);
734
735 if (status > 0)
736 {
737 var supportemail = Convert.ToString(ConfigurationManager.AppSettings["SupportEmail"] ?? "team@occfinance.com");
738 var ccmail = Convert.ToString(ConfigurationManager.AppSettings["CCEmail"] ?? "crispy50@hotmail.com");
739 var bccemail = Convert.ToString(ConfigurationManager.AppSettings["BCCEmail"] ?? "team@occfinance.com");
740
741
742 string body = "Hi, <br /><br />";
743 body += "Below is the new client registration request details.<br /><br />";
744 body += "Name: " + regenqname + "<br /><br />";
745 body += "Email: " + regenqemail + "<br /><br />";
746 body += "Telephone: " + regenqtel + "<br /><br />";
747 body += "Comapany Name: " + regcompanyname + "<br /><br />";
748 body += "Regards: <br /><br />";
749 body += "Administrator<br /><br />";
750 body += "OCC Finance<br /><br />";
751
752 var _secureURL = Convert.ToString(ConfigurationManager.AppSettings["SecureURL"] ?? "");
753 var _contentURL = Convert.ToString(ConfigurationManager.AppSettings["ContentURL"] ?? "");
754
755 var AppTrackImg = _secureURL + "/Content/images/" + Convert.ToString("apptrack.jpg");
756 var AppTrackLogo = _secureURL + "/Content/images/" + Convert.ToString(Session["SiteLogo"] ?? "logo_6569.jpg");
757 var FooterCopyRight = "© 2014 Finance Technology Ltd. Registered trademarks IntelliCalc®, AppTrack®. All rights reserved";
758 var SupportFooter = "Contact Us on: 0845 521 5153, Specialising in financial technologies & solutions";
759 var _mailTemplate = Codes.Extensions.Mailtemplates(AppTrackImg, AppTrackLogo, body, FooterCopyRight, SupportFooter, _contentURL);
760
761 List<ManDRILLModel> _mandrillOBJ = new List<ManDRILLModel>();
762 var _mailDrilEmails = new List<EmailAddress>();
763 EmailAddress objEm = new EmailAddress();
764 objEm.email = supportemail;
765 objEm.name = "";
766 _mailDrilEmails.Add(objEm);
767
768 objEm.email = ccmail;
769 objEm.name = "";
770 objEm.type = "cc";
771 _mailDrilEmails.Add(objEm);
772
773
774 objEm.email = bccemail;
775 objEm.name = "";
776 objEm.type = "bcc";
777 _mailDrilEmails.Add(objEm);
778
779 //Man DRILL ********************************************************************
780
781 var domain = "occfinance.com";
782 EmailMessage message = new EmailMessage();
783 var _mandrillMessage = new List<EmailMessage>();
784
785 message.to = _mailDrilEmails;
786 message.html = _mailTemplate;
787 message.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
788 message.from_name = "OCC";
789 message.subject = "New Registration Request";
790 message.inline_css = true;
791 message.signing_domain = domain;
792 message.AddHeader("X-MC-SigningDomain", domain);
793 message.AddHeader("X-MC-TrackingDomain", domain);
794 _mandrillMessage.Add(message);
795
796 //********************************************************************************
797
798 // Manage The ManDRILLModel - 25-07-2014
799
800 var objMAN = new ManDRILLModel();
801 objMAN.contactId = 0;
802 objMAN.financeid = 0;
803 objMAN.mailcontent = _mailTemplate;
804 objMAN.MandrillMSG = message;
805 objMAN.IsAppContact = false;
806
807 objMAN.notemsg = "";
808
809 _mandrillOBJ.Add(objMAN);
810
811 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
812 WebUtility.SendMailViaManDRILL(_mandrillOBJ, userId);
813
814 //***************************************
815
816
817
818
819 string bodyuser = "Hi " + regenqname + ", <br /><br />";
820 bodyuser += "Thanks for your interest to our products.<br /><br />";
821 bodyuser += "We will contact you shortly with your credential details.<br /><br />";
822 bodyuser += "Regards: <br /><br />";
823 bodyuser += "Administrator<br /><br />";
824 bodyuser += "OCC Finance<br /><br />";
825
826 var _mailTemplate1 = Codes.Extensions.Mailtemplates(AppTrackImg, AppTrackLogo, bodyuser, FooterCopyRight, SupportFooter, _contentURL);
827
828 //System.Threading.Tasks.Task.Run(() =>
829 //{
830 // MailHelper.SendMailMessage(regenqemail, bccemail, ccmail, "Greetings From OCC Finance", _mailTemplate1);
831 //});
832
833
834 List<ManDRILLModel> _mandrillOBJ1 = new List<ManDRILLModel>();
835
836 var _mailDrilEmails1 = new List<EmailAddress>();
837 EmailAddress objEm1 = new EmailAddress();
838 objEm1.email = regenqemail;
839 objEm1.name = "";
840 _mailDrilEmails1.Add(objEm1);
841
842 objEm1.email = ccmail;
843 objEm1.name = "";
844 objEm1.type = "cc";
845 _mailDrilEmails1.Add(objEm1);
846
847
848 objEm1.email = bccemail;
849 objEm1.name = "";
850 objEm1.type = "bcc";
851 _mailDrilEmails1.Add(objEm1);
852
853 //Man DRILL ********************************************************************
854
855 var domain1 = "occfinance.com";
856 EmailMessage message1 = new EmailMessage();
857 var _mandrillMessage1 = new List<EmailMessage>();
858
859 message1.to = _mailDrilEmails1;
860 message1.html = _mailTemplate1;
861 message1.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
862 message1.from_name = "OCC";
863 message1.subject = "Greetings From OCC Finance";
864 message1.inline_css = true;
865 message1.signing_domain = domain1;
866 message1.AddHeader("X-MC-SigningDomain", domain1);
867 message1.AddHeader("X-MC-TrackingDomain", domain1);
868 _mandrillMessage1.Add(message1);
869
870 //********************************************************************************
871
872 // Manage The ManDRILLModel - 25-07-2014
873
874 var objMAN1 = new ManDRILLModel();
875 objMAN1.contactId = 0;
876 objMAN1.financeid = 0;
877 objMAN1.mailcontent = _mailTemplate1;
878 objMAN1.MandrillMSG = message1;
879 objMAN1.IsAppContact = false;
880
881 objMAN1.notemsg = "";
882
883 _mandrillOBJ1.Add(objMAN1);
884
885
886 WebUtility.SendMailViaManDRILL(_mandrillOBJ1, userId);
887
888 }
889
890 }
891 catch(Exception ex)
892 {
893 Helper.ErrorLog(ex.InnerException, "HomeController", "Registration", ex.Message);
894
895 }
896 return Json(status, JsonRequestBehavior.AllowGet);
897 }
898
899 /// <summary>
900 /// Send issue email
901 /// </summary>
902 /// <param name="IndividualFolderName"></param>
903 /// <param name="name"></param>
904 /// <param name="email"></param>
905 /// <param name="issue"></param>
906 /// <param name="steps"></param>
907 /// <returns></returns>
908 [App_Start.SessionTimeOutActionFilter]
909 public ActionResult SendIssuemail(string IndividualFolderName, string name, string email, string issue, string steps)
910 {
911 int status = 0;
912 if (Session["LoggedInUserId"] != null)
913 {
914 var issueemail = Convert.ToString(ConfigurationManager.AppSettings["IssueEmail"] ?? "crispy50@hotmail.com");
915 var supportemail = Convert.ToString(ConfigurationManager.AppSettings["SupportEmail"] ?? "team@occfinance.com");
916 var ccmail = Convert.ToString(ConfigurationManager.AppSettings["CCEmail"] ?? "crispy50@hotmail.com");
917 var bccemail = Convert.ToString(ConfigurationManager.AppSettings["BCCEmail"] ?? "team@occfinance.com");
918
919
920 string body = "Hi, <br /><br />";
921 body += "I got an issue, need your support.<br /><br/>";
922 body += "Below is the issue details.<br /><br />";
923 body += "Issue: " + issue + "<br />";
924 body += "Step(s): " + steps + "<br /><br />";
925 body += "Regards: <br />";
926 body += name + "<br />";
927 body += email + "<br />";
928
929
930 string bodyuser = "Hi , " + name + " <br /><br />";
931 bodyuser += "Thanks for your feedbacks.<br />";
932 bodyuser += "We will definately short this out earliest.<br /><br />";
933 bodyuser += "Regards: <br />";
934 bodyuser += "Administrator<br />";
935 bodyuser += "OCC Finance<br />";
936
937
938 //Mail with multiple Attachement-----------(Mail to administration)-----------------------------------------------
939
940 string[] files = null;
941
942 string subPath = ConfigurationManager.AppSettings["MailAttachment"] + IndividualFolderName;
943 if (!string.IsNullOrWhiteSpace(IndividualFolderName))
944 {
945 if (!Directory.Exists(subPath))
946 {
947 files = new string[Directory.GetFiles(Server.MapPath(subPath)).Length];
948 for (int i = 0; i < Directory.GetFiles(Server.MapPath(subPath)).Length; i++)
949 {
950 files[i] = Directory.GetFiles(Server.MapPath(subPath))[i];
951 }
952 }
953 }
954
955 //Issue mail to the admin
956 System.Threading.Tasks.Task.Run(() =>
957 {
958 MailHelper.SendMailMessageWithMultipleAttachments(issueemail, bccemail, ccmail, "ISSUE ON AppTrack", body, files);
959 //MailHelper.SendMailMessageTwo(issueemail, bccemail, ccmail, "ISSUE ON AppTrack", body, files[0], files[1]);
960 });
961
962
963
964 //Acknowledgement mail to the user
965 //System.Threading.Tasks.Task.Run(() =>
966 //{
967 // MailHelper.SendMailMessage(email, bccemail, ccmail, "Reply Mail from OCC Finance", bodyuser);
968 //});
969
970
971 List<ManDRILLModel> _mandrillOBJ = new List<ManDRILLModel>();
972
973 var _mailDrilEmails = new List<EmailAddress>();
974 EmailAddress objEm = new EmailAddress();
975
976 objEm.email = email;
977 objEm.name = "";
978 _mailDrilEmails.Add(objEm);
979
980 objEm.email = ccmail;
981 objEm.name = "";
982 objEm.type = "cc";
983 _mailDrilEmails.Add(objEm);
984
985
986 objEm.email = bccemail;
987 objEm.name = "";
988 objEm.type = "bcc";
989 _mailDrilEmails.Add(objEm);
990
991 //Man DRILL ********************************************************************
992
993 var domain = "occfinance.com";
994 EmailMessage message = new EmailMessage();
995 var _mandrillMessage = new List<EmailMessage>();
996
997 message.to = _mailDrilEmails;
998 message.html = bodyuser;
999 message.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
1000 message.from_name = "OCC";
1001 message.subject = "Reply Mail from OCC Finance";
1002 message.inline_css = true;
1003 message.signing_domain = domain;
1004 message.AddHeader("X-MC-SigningDomain", domain);
1005 message.AddHeader("X-MC-TrackingDomain", domain);
1006 _mandrillMessage.Add(message);
1007
1008 //********************************************************************************
1009
1010 // Manage The ManDRILLModel - 25-07-2014
1011
1012 var objMAN = new ManDRILLModel();
1013 objMAN.contactId = 0;
1014 objMAN.financeid = 0;
1015 objMAN.mailcontent = bodyuser;
1016 objMAN.MandrillMSG = message;
1017 objMAN.IsAppContact = false;
1018
1019 objMAN.notemsg = "";
1020
1021 _mandrillOBJ.Add(objMAN);
1022
1023 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
1024 WebUtility.SendMailViaManDRILL(_mandrillOBJ, userId);
1025 status = 1;
1026 }
1027 else
1028 {
1029 status = -2;
1030 }
1031 return Json(status, JsonRequestBehavior.AllowGet);
1032 }
1033
1034 #region rendering Login Page
1035 /// <summary>
1036 /// Login page rendering
1037 /// </summary>
1038 /// <param name="encrypted"></param>
1039 /// <returns></returns>
1040 public ActionResult Index(string encrypted = "")
1041 {
1042 //Added on 2015-03-13
1043 try
1044 {
1045 Session.Clear();
1046 Session.Abandon();
1047 Session.RemoveAll();
1048 CookieWrapper.ClientRegistrationID = 0;
1049 CookieWrapper.UserId = 0;
1050 Response.Cookies.Clear();
1051 Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
1052 ViewBag.FormAction = "DoLogin";
1053 if (!string.IsNullOrEmpty(encrypted))
1054 ViewBag.UserName = WebUtility.DecryptString(encrypted);
1055 else
1056 ViewBag.UserName = encrypted;
1057 }
1058 catch (Exception ex)
1059 {
1060 Helper.ErrorLog(ex.InnerException, "HomeController", "Index", ex.Message);
1061 ViewBag.FormAction = "DoLogin";
1062 ViewBag.UserName = string.Empty;
1063 }
1064 return View();
1065 }
1066 #endregion
1067
1068 /// <summary>
1069 /// Secure login
1070 /// </summary>
1071 /// <param name="u"></param>
1072 /// <param name="p"></param>
1073 /// <param name="isApp"></param>
1074 /// <param name="url"></param>
1075 /// <returns></returns>
1076 public ActionResult SecureLogin(string u, string p, int isApp, string url)
1077 {
1078 string name = u;
1079 string password = p;
1080 string fromurl = url;
1081 int userid = 0;
1082
1083 if (isApp == 1)
1084 {
1085 int ClientRegistrationID = 0;
1086 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
1087 {
1088 con.Open();
1089 SqlTransaction trans = con.BeginTransaction();
1090 try
1091 {
1092 ClientRegistrationID = Qmortgage.GetRegistar(name, password, true, trans, con);
1093 trans.Commit();
1094
1095 }
1096 catch (SqlException ex)
1097 {
1098 Helper.ErrorLog(ex.InnerException, "HomeController", "SecureLogin", ex.Message);
1099 trans.Rollback();
1100
1101 }
1102 finally
1103 {
1104 con.Close();
1105 }
1106
1107 }
1108 if (ClientRegistrationID == 0)
1109 {
1110 return RedirectToAction("InValidLogin", "Home");
1111 }
1112 else
1113 {
1114 Session["ClientRegistrationID"] = ClientRegistrationID;
1115 CookieWrapper.ClientRegistrationID = ClientRegistrationID;
1116 return RedirectToAction("mortgage_fact_find", "Apptrack");
1117 }
1118 }
1119 else
1120 {
1121
1122 bool check = Quser.AuthenticateUser(name, password, out userid);
1123 // CookieWrapper.CheckDesktop = "True";
1124 if (url == ConfigurationManager.AppSettings["ContentURL"])
1125 {
1126 if (check)
1127 {
1128 Session["IsValidUser"] = true;
1129 Session["LoggedInUserId"] = userid;
1130 Session["SiteLogo"] = "apptrack.jpg";
1131
1132 //Initialoze Permissions Settings -- 17-07-2014
1133 QSetting.GetSetPermission(userid);
1134 //*********************************
1135
1136 var client = Qclient.FindClientByLoggedUser(userid);
1137 if (client != null)
1138 {
1139 Session["ContactName"] = client.username;
1140 Session["ContactEmail"] = client.email;
1141 Session["LoggedInUserAccountId"] = client.clientid;
1142 Session["telephone"] = client.telephone;
1143 Session["PrimaryContact"] = client.PrimaryContact;
1144 Session["SecondaryContact"] = client.SecondaryContact;
1145 Session["Address1"] = client.Address1;
1146 Session["Address2"] = client.Address2;
1147 Session["OtherDetails"] = client.OtherDetails;
1148 Session["Fax"] = client.FAX;
1149 Session["Qualification"] = client.Qualification;
1150 Session["Title"] = client.Title;
1151
1152 CookieWrapper.UserId = userid;
1153
1154 if (System.IO.File.Exists(Server.MapPath("~/content/images/logo_" + client.clientid + ".jpg")))
1155 {
1156 Session["SiteLogo"] = "logo_" + client.clientid + ".jpg";
1157 }
1158 else if (System.IO.File.Exists(Server.MapPath("~/content/images/logo_" + client.parent + ".jpg")))
1159 {
1160 Session["SiteLogo"] = "logo_" + client.parent + ".jpg";
1161 }
1162
1163 try
1164 {
1165 var dAttendance = Qclient.GetAvailableHoursDays(userid, DateTime.Now, DateTime.Now.Year);
1166 Session["AllowedDays"] = dAttendance.AllowedDays;
1167 Session["AllowedHours"] = dAttendance.AllowedHours;
1168 Session["UsedDays"] = dAttendance.UsedDays;
1169 Session["UsedHours"] = dAttendance.UsedHours;
1170 }
1171 catch(Exception ex)
1172 {
1173 Helper.ErrorLog(ex.InnerException, "HomeController", "SecureLogin", ex.Message);
1174 }
1175
1176 try
1177 {
1178 Session["DefaultsettingId"] = Qclient.GetTotalDays(client.clientid);
1179 }
1180 catch(Exception ex)
1181 {
1182 Helper.ErrorLog(ex.InnerException, "HomeController", "SecureLogin", ex.Message);
1183 }
1184
1185 try
1186 {
1187 int teamId = 0;
1188 string brokersIds = "";
1189 int _userType = 0;
1190 int _accountId = 0;
1191 Q_Application _obj = new Q_Application();
1192 _userType = _obj.CheckUserType(CookieWrapper.UserId, out teamId, out _accountId, out brokersIds);
1193 Session["UserType"] = _userType;
1194
1195 }
1196 catch (Exception ex)
1197 {
1198
1199 Helper.ErrorLog(ex.InnerException, "HomeController", "SecureLogin", ex.Message);
1200 }
1201 }
1202 if (!string.IsNullOrEmpty(CookieWrapper.CheckDesktop) && CookieWrapper.CheckDesktop == "False")
1203 {
1204 return RedirectToAction("Applications", "Apptrack");
1205 }
1206 else
1207 {
1208
1209
1210 CookieWrapper.CheckDesktop = "True";
1211 return RedirectToAction("Dashboard", "Apptrack");
1212 }
1213 }
1214 else
1215 {
1216 return RedirectToAction("InValidLogin", "Home");
1217 }
1218 }
1219 else
1220 {
1221 return Redirect(ConfigurationManager.AppSettings["ContentURL"]);
1222 }
1223 }
1224
1225 }
1226
1227 #region [Added on 2015-02-09 Authentication section]
1228
1229 /// <summary>
1230 /// do login method
1231 /// </summary>
1232 /// <param name="fc"></param>
1233 /// <returns></returns>
1234 public ActionResult DoLogin(FormCollection fc)
1235 {
1236
1237 string name = fc["LoginUserName"];
1238 string password = fc["Loginpassword"];
1239 if (fc["SecureLogin"] == "on")
1240 {
1241 int ClientRegistrationID = 0;
1242 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
1243 {
1244 con.Open();
1245 SqlTransaction trans = con.BeginTransaction();
1246 try
1247 {
1248 ClientRegistrationID = Qmortgage.GetRegistar(name, password, true, trans, con);
1249 trans.Commit();
1250
1251 }
1252 catch (SqlException ex)
1253 {
1254
1255 Helper.ErrorLog(ex.InnerException, "HomeController", "DoLogin", ex.Message);
1256 trans.Rollback();
1257
1258 }
1259 finally
1260 {
1261 con.Close();
1262 }
1263
1264 }
1265 if (ClientRegistrationID == 0)
1266 {
1267 return RedirectToAction("InValidLogin", "Home");
1268 }
1269 else
1270 {
1271 Session["ClientRegistrationID"] = ClientRegistrationID;
1272 Session["DefaultCurrency"] = QSetting.GetDefaultCurrency();
1273 CookieWrapper.ClientRegistrationID = ClientRegistrationID;
1274 CookieWrapper.UserId =0;
1275 return RedirectToAction("mortgage_fact_find", "Apptrack");
1276 }
1277 }
1278 else
1279 {
1280
1281 Session["SiteLogo"] = "apptrack.jpg";
1282 int userid = 0;
1283 bool check = Quser.AuthenticateUser(name, password, out userid);
1284 // CookieWrapper.CheckDesktop = "True";
1285
1286 if (check)
1287 {
1288 Session["IsValidUser"] = true;
1289 Session["LoggedInUserId"] = userid;
1290 Session["DefaultCurrency"] = QSetting.GetDefaultCurrency();
1291 //Initialoze Permissions Settings -- 17-07-2014
1292 QSetting.GetSetPermission(userid);
1293 //*********************************
1294
1295 var client = Qclient.FindClientByLoggedUser(userid);
1296
1297 if (client != null)
1298 {
1299 Session["ContactName"] = client.username;
1300 Session["ContactEmail"] = client.email;
1301 Session["LoggedInUserAccountId"] = client.clientid;
1302 Session["telephone"] = client.telephone;
1303 Session["PrimaryContact"] = client.PrimaryContact;
1304 Session["SecondaryContact"] = client.SecondaryContact;
1305 Session["Address1"] = client.Address1;
1306 Session["Address2"] = client.Address2;
1307 Session["OtherDetails"] = client.OtherDetails;
1308 Session["Fax"] = client.FAX;
1309 Session["Qualification"] = client.Qualification;
1310 Session["Title"] = client.Title;
1311 Session["CompanyName"] = client.companyname;
1312
1313 CookieWrapper.UserId = userid;
1314 string subPath = System.Configuration.ConfigurationManager.AppSettings["BrokerImages"] ?? "~/Content/BrokerImages/";
1315 string brokerImage = ctx.tblusers.Where(res => res.userid == userid).Select(res => res.BrokerImage).FirstOrDefault();
1316 Session["BrokerImage"] = subPath + (string.IsNullOrEmpty(brokerImage) ? "noimage.jpg" : brokerImage).ToString();
1317 if (client != null)
1318 {
1319 Session["LoggedInUserAccountId"] = client.clientid;
1320 if (System.IO.File.Exists(Server.MapPath("~/content/images/logo_" + client.clientid + ".jpg")))
1321 {
1322 Session["SiteLogo"] = "logo_" + client.clientid + ".jpg";
1323 }
1324 else if (System.IO.File.Exists(Server.MapPath("~/content/images/logo_" + client.parent + ".jpg")))
1325 {
1326 Session["SiteLogo"] = "logo_" + client.parent + ".jpg";
1327 }
1328 }
1329
1330 try
1331 {
1332 var dAttendance = Qclient.GetAvailableHoursDays(userid, DateTime.Now, DateTime.Now.Year);
1333 Session["AllowedDays"] = dAttendance.AllowedDays;
1334 Session["AllowedHours"] = dAttendance.AllowedHours;
1335 Session["UsedDays"] = dAttendance.UsedDays;
1336 Session["UsedHours"] = dAttendance.UsedHours;
1337 }
1338 catch(Exception ex)
1339 {
1340 Helper.ErrorLog(ex.InnerException, "HomeController", "DoLogin", ex.Message);
1341 }
1342
1343 try
1344 {
1345 Session["DefaultsettingId"] = Qclient.GetTotalDays(client.clientid);
1346 }
1347 catch (Exception ex)
1348 {
1349 Helper.ErrorLog(ex.InnerException, "HomeController", "DoLogin", ex.Message);
1350 }
1351
1352 try
1353 {
1354 int teamId = 0;
1355 string brokersIds = "";
1356 int _userType = 0;
1357 int _accountId = 0;
1358 Q_Application _obj = new Q_Application();
1359 _userType = _obj.CheckUserType(CookieWrapper.UserId, out teamId, out _accountId, out brokersIds);
1360 Session["UserType"] = _userType;
1361 Session["UserTypeName"] = QSetting.GetUserType(SessionHelper.UserId,out _userType);
1362
1363
1364 }
1365 catch (Exception ex)
1366 {
1367 Helper.ErrorLog(ex.InnerException, "HomeController", "DoLogin", ex.Message);
1368 }
1369 }
1370 if (!string.IsNullOrEmpty(CookieWrapper.CheckDesktop) && CookieWrapper.CheckDesktop == "False")
1371 {
1372 return RedirectToAction("Applications", "Apptrack");
1373 }
1374 else
1375 {
1376
1377
1378 CookieWrapper.CheckDesktop = "True";
1379 int teamId = 0;
1380 string brokersIds = "";
1381 int _userType = 0;
1382 int _accountId = 0;
1383 Q_Application _obj = new Q_Application();
1384 _userType = _obj.CheckUserType(CookieWrapper.UserId, out teamId, out _accountId, out brokersIds);
1385
1386
1387 Session["UserType"] = _userType;
1388 if (_userType == 3|| _userType == 4)
1389 {
1390 return RedirectToAction("TiledDashboard", "Apptrack");
1391 }
1392 else
1393 {
1394 return RedirectToAction("Dashboard", "Apptrack");
1395 }
1396 }
1397 }
1398 else
1399 {
1400 return RedirectToAction("InValidLogin", "Home");
1401 }
1402 }
1403
1404 }
1405 /// <summary>
1406 /// Get user type on the basis of user type id
1407 /// </summary>
1408 /// <param name="_userType"></param>
1409 /// <returns></returns>
1410 public string GetUserTypeName(int _userType)
1411 {
1412 if (_userType == 1)
1413 return "Admin";
1414 else if (_userType == 3)
1415 return "Broker";
1416 else if (_userType == 2)
1417 return "Manager";
1418 else if (_userType == 4)
1419 return "GeneralUser";
1420 else
1421 return string.Empty;
1422 }
1423
1424 #endregion [Added on 2015-02-09]
1425
1426 /// <summary>
1427 /// Invalid login method
1428 /// </summary>
1429 /// <returns></returns>
1430 public ActionResult InValidLogin()
1431 {
1432 ViewBag.FormAction = "DoLogin";
1433 return View();
1434 }
1435
1436 /// <summary>
1437 /// Reset password
1438 /// </summary>
1439 /// <param name="Email"></param>
1440 /// <returns></returns>
1441 public ActionResult ResetPassword(string Email)
1442 {
1443 int status = 0;
1444 if (!ctx.tblusers.Where(c => c.username.ToLower().Trim() == Email.ToLower().Trim()).Any())
1445 {
1446 status = 0;
1447 }
1448 else
1449 {
1450 var data = ctx.tblusers.Where(c => c.username.ToLower().Trim() == Email.ToLower().Trim()).FirstOrDefault();
1451 if (data != null)
1452 {
1453 string body = "Hi, <br /><br />";
1454 body += "Your Password is: " + data.password + "<br />";
1455 body += "Regards: <br />";
1456 body += "Administrator <br />";
1457 body += "OCC Finance<br />";
1458
1459 //System.Threading.Tasks.Task.Run(() =>
1460 //{
1461 // MailHelper.SendMailMessage(Email, "", "", "Password Request", body);
1462 //});
1463
1464 //------------------------------------------------------------
1465
1466 List<ManDRILLModel> _mandrillOBJ = new List<ManDRILLModel>();
1467
1468 var _mailDrilEmails = new List<EmailAddress>();
1469 EmailAddress objEm = new EmailAddress();
1470 objEm.email = Email;
1471 objEm.name = "";
1472 _mailDrilEmails.Add(objEm);
1473
1474 //Man DRILL ********************************************************************
1475
1476 var domain = "occfinance.com";
1477 EmailMessage message = new EmailMessage();
1478 var _mandrillMessage = new List<EmailMessage>();
1479
1480 message.to = _mailDrilEmails;
1481 message.html = body;
1482 message.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
1483 message.from_name = "OCC";
1484 message.subject = "Password Request";
1485 message.inline_css = true;
1486 message.signing_domain = domain;
1487 message.AddHeader("X-MC-SigningDomain", domain);
1488 message.AddHeader("X-MC-TrackingDomain", domain);
1489 _mandrillMessage.Add(message);
1490
1491 //********************************************************************************
1492
1493 // Manage The ManDRILLModel - 25-07-2014
1494
1495 var objMAN = new ManDRILLModel();
1496 objMAN.contactId = 0;
1497 objMAN.financeid = 0;
1498 objMAN.mailcontent = body;
1499 objMAN.MandrillMSG = message;
1500 objMAN.IsAppContact = false;
1501
1502 objMAN.notemsg = "";
1503
1504 _mandrillOBJ.Add(objMAN);
1505
1506 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
1507 WebUtility.SendMailViaManDRILL(_mandrillOBJ, userId);
1508
1509 //------------------------------------------------------------
1510
1511 status = 1;
1512 }
1513 }
1514 return Json(status, JsonRequestBehavior.AllowGet);
1515 }
1516
1517 /// <summary>
1518 /// Add Template
1519 /// </summary>
1520 /// <param name="templateid"></param>
1521 /// <param name="name"></param>
1522 /// <param name="subject"></param>
1523 /// <param name="body"></param>
1524 /// <returns></returns>
1525 [ValidateInput(false)]
1526 public ActionResult AddTemplate(int templateid, string name, string subject, string body)
1527 {
1528 int chk = AddUpdate(templateid, name, subject, body);
1529 return Json(chk, JsonRequestBehavior.AllowGet);
1530 }
1531
1532 /// <summary>
1533 /// Send email
1534 /// </summary>
1535 /// <param name="templateid"></param>
1536 /// <param name="chk"></param>
1537 /// <param name="name"></param>
1538 /// <param name="EmailId"></param>
1539 /// <param name="FinanceId"></param>
1540 /// <param name="toall"></param>
1541 /// <param name="ContactArray"></param>
1542 /// <param name="subject"></param>
1543 /// <param name="body"></param>
1544 /// <param name="followUp"></param>
1545 /// <param name="IsMortgageClientInclude"></param>
1546 /// <returns></returns>
1547 [ValidateInput(false)]
1548 [App_Start.SessionTimeOutActionFilter]
1549 public ActionResult SendEmail(int templateid, int chk, string name, string EmailId, int FinanceId, int toall, List<ContactMail> ContactArray, string subject, string body, bool followUp = false /* added on 28 01 2015 for followup */, bool IsMortgageClientInclude = true)
1550 {
1551 int _chk = 0;
1552 var _contentURL = "occfinance.com";
1553 if (Session["LoggedInUserId"] != null)
1554 {
1555 try
1556 {
1557 if (string.IsNullOrWhiteSpace(subject))
1558 subject = "Mail From OCC Finance";
1559
1560 string _McAPIKey = Convert.ToString(ConfigurationManager.AppSettings["MailChimpApikey"] ?? "");
1561 MailChimpManager _mcmanager = new MailChimpManager(Convert.ToString(ConfigurationManager.AppSettings["MailChimpApikey"] ?? ""));
1562 var _mailDrilEmails = new List<EmailAddress>();
1563 var _mandrillMessage = new List<EmailMessage>();
1564 List<ManDRILLModel> _mandrillOBJ = new List<ManDRILLModel>();
1565
1566 int loggedinuserid = Convert.ToInt32(Session["LoggedInUserId"] ?? 0);
1567 var _userName = Convert.ToString(Session["ContactName"] ?? "");
1568 var _usertel = Convert.ToString(Session["telephone"] ?? "");
1569 var _useremail = Convert.ToString(Session["ContactEmail"] ?? "");
1570
1571 if (chk == 1)
1572 {
1573 AddUpdate(templateid, name, subject, body);
1574 }
1575
1576 IQueryable<ApplicationLead> allLead = null;
1577 if (Session["LeadData"] != null)
1578 allLead = (IQueryable<ApplicationLead>)Session["LeadData"];
1579
1580 //Get new latest NoteId *****************************
1581 Q_Application _qA = new Q_Application();
1582 //int _noteid = _qA.getNoteID();
1583 //***************************************************
1584
1585 if (!string.IsNullOrWhiteSpace(EmailId) && FinanceId != 0 && toall == 0)
1586 {
1587
1588
1589 //int typeid = Convert.ToInt32(Session["DefaultsettingId"] ?? 1);
1590 //int loggedinuser = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
1591 Q_Application QApplication = new Q_Application();
1592 //List<StatusCount> _listStatusCount = new List<StatusCount>();
1593 //allLead = QApplication.GetAllLead(out _listStatusCount, Convert.ToInt32(Session["LoggedInUserAccountId"]), loggedinuser, typeid, Convert.ToString(Session["Search"] ?? ""), 0, "", "", "", "", 0);
1594
1595 var obj = new ApplicationJsonLead();
1596 if (allLead == null)
1597 {
1598 var objMain = ctx.tblfinances.Where(c => c.financeid == FinanceId).FirstOrDefault();
1599 obj = QApplication.GetSingleLead(0, objMain.contact ?? 0, objMain.financeid);
1600 }
1601 else
1602 {
1603 var objMain = allLead.Where(c => c.financeid == FinanceId).FirstOrDefault();
1604 obj = QApplication.GetSingleLead(objMain.AccountId, objMain.contactId, objMain.financeid);
1605 }
1606 bool IsUnsubscribed = false;
1607
1608 //Check if contact is unsubscribed 2014-11-20
1609 if (WebUtility.UnsubscribeEmail(obj.contactId, 3) == 3)
1610 {
1611 return Json(-3, JsonRequestBehavior.AllowGet);
1612 }
1613
1614
1615 if (obj != null)
1616 {
1617 string _mailcontent = MailContentTemplate(
1618 body,
1619 obj.firstName,
1620 obj.lastName,
1621 (obj.followUp.HasValue ? obj.followUp.Value.ToString("dd/MM/yyyy") : "").ToString(),
1622 obj.tel, _usertel, _userName, _useremail,
1623 obj.brokerName ?? "",
1624 obj.clientname ?? "", obj.brokerName ?? "", obj.PolicyNumber ?? "", obj.Lender ?? "", obj.Soliciter ?? "", obj.PrimaryContact ?? "", obj.SecondaryContact ?? "", obj.Address1 ?? "", obj.Address2 ?? "", obj.OtherDetails ?? "", obj.Title ?? "", obj.FAX ?? "", obj.Qualification ?? "", Convert.ToString(obj.contactId) ?? "");
1625
1626
1627
1628 //Add Notes to the note table**************************************************
1629 string HTML_TAG_PATTERN = @"<[^>]+>| ";
1630
1631 // Create the email parameter
1632 try
1633 {
1634 _mailDrilEmails = new List<EmailAddress>();
1635 EmailAddress objEm = new EmailAddress();
1636 objEm.email = EmailId;
1637 objEm.name = obj.firstName + " " + obj.lastName;
1638 _mailDrilEmails.Add(objEm);
1639
1640 //Man DRILL ********************************************************************
1641
1642 EmailMessage message = new EmailMessage();
1643 message.to = _mailDrilEmails;
1644 message.html = _mailcontent;
1645 message.from_email = obj.BrokerEmail ?? "";
1646 message.from_name = obj.brokerName ?? "";
1647 message.subject = subject;
1648 message.inline_css = true;
1649 message.signing_domain = _contentURL;
1650 message.AddHeader("X-MC-SigningDomain", _contentURL);
1651 message.AddHeader("X-MC-TrackingDomain", _contentURL);
1652 _mandrillMessage.Add(message);
1653
1654 //********************************************************************************
1655
1656 // Manage The ManDRILLModel - 25-07-2014
1657
1658 var objMAN = new ManDRILLModel();
1659 objMAN.contactId = obj.contactId;
1660 objMAN.financeid = obj.financeid;
1661 objMAN.mailcontent = _mailcontent;
1662 objMAN.MandrillMSG = message;
1663 objMAN.IsAppContact = false;
1664 objMAN.TemplateName = name;
1665 objMAN.Status = obj.status ?? 0;
1666 objMAN.notemsg = "Email correspondence sent : " + System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(_mailcontent, HTML_TAG_PATTERN, " "), @"\s{2,}", " ");
1667
1668 _mandrillOBJ.Add(objMAN);
1669
1670 }
1671 catch(Exception ex)
1672 {
1673 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmail", ex.Message);
1674 }
1675 // Track Mail
1676
1677
1678 if (!string.IsNullOrWhiteSpace(obj.OtherApplicantEmail))
1679 {
1680 if (!EmailId.GetString().Equals(obj.OtherApplicantEmail.GetString(), StringComparison.OrdinalIgnoreCase))
1681 {
1682 string _mailcontentother = MailContentTemplate(
1683 body,
1684 obj.OtherApplicantFname,
1685 obj.OtherApplicantSName,
1686 (obj.followUp.HasValue ? obj.followUp.Value.ToString("dd/MM/yyyy") : "").ToString(),
1687 obj.OtherApplicantMobile,
1688 _usertel, _userName, _useremail,
1689 obj.brokerName ?? "",
1690 obj.clientname ?? "", obj.BrokerEmail ?? "", obj.PolicyNumber ?? "", obj.Lender ?? "", obj.Soliciter ?? "", obj.PrimaryContact ?? "", obj.SecondaryContact ?? "", obj.Address1 ?? "", obj.Address2 ?? "", obj.OtherDetails ?? "", obj.Title ?? "", obj.FAX ?? "", obj.Qualification ?? "", Convert.ToString(obj.contactId) ?? "");
1691
1692
1693
1694 // This below functiona to subscribe the user into the mail chimp (Need to add functionality through Mail Chimp)
1695 // Create the email parameter
1696 try
1697 {
1698 _mailDrilEmails = new List<EmailAddress>();
1699 EmailAddress objEm = new EmailAddress();
1700 objEm.email = obj.OtherApplicantEmail;
1701 objEm.name = obj.OtherApplicantFname + " " + obj.OtherApplicantSName;
1702 _mailDrilEmails.Add(objEm);
1703
1704 //Man DRILL ********************************************************************
1705 EmailMessage message = new EmailMessage();
1706 message.to = _mailDrilEmails;
1707 message.html = _mailcontentother;
1708 message.from_email = obj.BrokerEmail ?? "";
1709 message.from_name = obj.brokerName ?? "";
1710 message.subject = subject;
1711 message.inline_css = true;
1712 message.signing_domain = _contentURL;
1713 message.AddHeader("X-MC-SigningDomain", _contentURL);
1714 message.AddHeader("X-MC-TrackingDomain", _contentURL);
1715 _mandrillMessage.Add(message);
1716
1717 // Manage The ManDRILLModel - 25-07-2014
1718
1719 var objMAN = new ManDRILLModel();
1720 objMAN.contactId = obj.contactId;
1721 objMAN.financeid = 0;
1722 objMAN.mailcontent = _mailcontentother;
1723 objMAN.MandrillMSG = message;
1724 objMAN.IsAppContact = true;
1725 objMAN.Status = obj.status ?? 0;
1726 objMAN.notemsg = "Email correspondence sent : " + System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(_mailcontent, HTML_TAG_PATTERN, " "), @"\s{2,}", " ");
1727 objMAN.TemplateName = name;
1728 _mandrillOBJ.Add(objMAN);
1729
1730 //
1731 }
1732 catch(Exception ex)
1733 {
1734 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmail", ex.Message);
1735 }
1736 // Track Mail
1737 }
1738 }
1739
1740 }
1741
1742 if (WebUtility.SendMailViaManDRILL(_mandrillOBJ, loggedinuserid, followUp))
1743 _chk = 1;
1744
1745 }
1746 else if (toall == 2 && ContactArray != null && ContactArray.Count() > 0)
1747 {
1748 //List<MailSentStatus> _listMailStatus = new List<MailSentStatus>();
1749 //_listMailStatus = allLead.Select(c => new MailSentStatus
1750 //{
1751 // EmailId = c.email,
1752 // Status = 0
1753 //}).Distinct().ToList().Where(c => !string.IsNullOrWhiteSpace(c.EmailId)).ToList();
1754 //***************************************************************************
1755 var count = 0;
1756 List<int> lstContactIds = new List<int>();
1757 List<string> emails = new List<string>();
1758 foreach (var objC in ContactArray)
1759 {
1760
1761 // var obj = allLead.Where(c => c.financeid == objC.financeid).FirstOrDefault();
1762
1763 //Added for Latest Data-----------------------
1764 Q_Application QApplication = new Q_Application();
1765
1766 FinanceId = objC.financeid;
1767
1768
1769 var obj = new ApplicationJsonLead();
1770 if (allLead == null)
1771 {
1772 var objMain = ctx.tblfinances.Where(c => c.financeid == FinanceId).FirstOrDefault();
1773 obj = QApplication.GetSingleLead(0, objMain.contact ?? 0, objMain.financeid);
1774 }
1775 else
1776 {
1777 var objMain = allLead.Where(c => c.financeid == FinanceId).FirstOrDefault();
1778 obj = QApplication.GetSingleLead(objMain.AccountId, objMain.contactId, objMain.financeid);
1779 }
1780 List<int> lstContactId = new List<int>();
1781 //Check for unsubscribed contacts 2014-11-20
1782 if (WebUtility.UnsubscribeEmail(objC.contactid, 3) != 3)
1783 {
1784 string _mailcontent = MailContentTemplate(
1785 body,
1786 obj.firstName,
1787 obj.lastName,
1788 (obj.followUp.HasValue ? obj.followUp.Value.ToString("dd/MM/yyyy") : "").ToString(),
1789 obj.tel,
1790 Convert.ToString(Session["telephone"] ?? ""),
1791 Convert.ToString(Session["ContactName"] ?? ""),
1792 Convert.ToString(Session["ContactEmail"] ?? ""),
1793 obj.brokerName ?? "",
1794 obj.clientname ?? "", obj.BrokerEmail ?? "", obj.PolicyNumber ?? "", obj.Lender ?? "", obj.Soliciter ?? "", obj.PrimaryContact ?? "", obj.SecondaryContact ?? "", obj.Address1 ?? "", obj.Address2 ?? "", obj.OtherDetails ?? "", obj.Title ?? "", obj.FAX ?? "", obj.Qualification ?? "", Convert.ToString(obj.contactId) ?? "");
1795
1796
1797 if (!string.IsNullOrWhiteSpace(obj.email)) // && _listMailStatus.Where(c => c.EmailId == obj.email && c.Status == 1).Count() == 0 // Apply within if condition once mail will be sent once for a single contact regardsless of multiple products
1798 {
1799 try
1800 {
1801 // check if email exists
1802 if (!emails.Contains(obj.email))
1803 {
1804 emails.Add(obj.email);
1805 //Add Notes to the note table**************************************************
1806 string HTML_TAG_PATTERN = @"<[^>]+>| ";
1807 _mailDrilEmails = new List<EmailAddress>();
1808 EmailAddress objEm = new EmailAddress();
1809 objEm.email = obj.email;
1810 objEm.name = obj.firstName + " " + obj.lastName;
1811 _mailDrilEmails.Add(objEm);
1812
1813 //Man DRILL ********************************************************************
1814 EmailMessage message = new EmailMessage();
1815 message.to = _mailDrilEmails;
1816 message.html = _mailcontent;
1817 message.from_email = obj.BrokerEmail ?? "";
1818 message.from_name = obj.brokerName ?? "";
1819 message.subject = subject;
1820 message.inline_css = true;
1821 message.signing_domain = _contentURL;
1822 message.AddHeader("X-MC-SigningDomain", _contentURL);
1823 message.AddHeader("X-MC-TrackingDomain", _contentURL);
1824 _mandrillMessage.Add(message);
1825 // Manage The ManDRILLModel - 25-07-2014
1826
1827 var objMAN = new ManDRILLModel();
1828 objMAN.contactId = obj.contactId;
1829 objMAN.financeid = obj.financeid;
1830 objMAN.mailcontent = _mailcontent;
1831 objMAN.MandrillMSG = message;
1832 objMAN.IsAppContact = false;
1833 objMAN.Status = obj.status ?? 0;
1834 objMAN.notemsg = "Email correspondence sent : " + System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(_mailcontent, HTML_TAG_PATTERN, " "), @"\s{2,}", " ");
1835 objMAN.TemplateName = name;
1836 _mandrillOBJ.Add(objMAN);
1837 }
1838 }
1839 catch(Exception ex)
1840 {
1841 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmail", ex.Message);
1842 }
1843
1844 }
1845
1846
1847 //******************************************************************************
1848
1849 // ****************************** Send Mail to other Applicant ******************************
1850 if (!string.IsNullOrWhiteSpace(obj.OtherApplicantEmail))
1851 {
1852 if (!emails.Contains(obj.OtherApplicantEmail))
1853 {
1854 // check for other application email
1855 if (!obj.email.GetString().Equals(obj.OtherApplicantEmail.GetString(), StringComparison.OrdinalIgnoreCase))
1856 {
1857 emails.Add(obj.OtherApplicantEmail);
1858 string _mailcontentother = MailContentTemplate(
1859 body,
1860 obj.OtherApplicantFname,
1861 obj.OtherApplicantSName,
1862 (obj.followUp.HasValue ? obj.followUp.Value.ToString("dd/MM/yyyy") : "").ToString(),
1863 obj.OtherApplicantMobile,
1864 Convert.ToString(Session["telephone"] ?? ""),
1865 Convert.ToString(Session["ContactName"] ?? ""),
1866 Convert.ToString(Session["ContactEmail"] ?? ""),
1867 obj.brokerName ?? "",
1868 obj.clientname ?? "", obj.BrokerEmail ?? "", obj.PolicyNumber ?? "", obj.Lender ?? "", obj.Soliciter ?? "", obj.PrimaryContact ?? "", obj.SecondaryContact ?? "", obj.Address1 ?? "", obj.Address2 ?? "", obj.OtherDetails ?? "", obj.Title ?? "", obj.FAX ?? "", obj.Qualification ?? "", Convert.ToString(obj.contactId) ?? "");
1869
1870 try
1871 {
1872 _mailDrilEmails = new List<EmailAddress>();
1873 EmailAddress objEm = new EmailAddress();
1874 objEm.email = obj.OtherApplicantEmail;
1875 objEm.name = obj.OtherApplicantFname + " " + obj.OtherApplicantSName;
1876 _mailDrilEmails.Add(objEm);
1877
1878 //Man DRILL ********************************************************************
1879 EmailMessage message = new EmailMessage();
1880 message.to = _mailDrilEmails;
1881 message.html = _mailcontentother;
1882 message.from_email = obj.BrokerEmail ?? "";
1883 message.from_name = obj.brokerName ?? "";
1884 message.subject = subject;
1885 message.inline_css = true;
1886 message.signing_domain = _contentURL;
1887 message.AddHeader("X-MC-SigningDomain", _contentURL);
1888 message.AddHeader("X-MC-TrackingDomain", _contentURL);
1889 _mandrillMessage.Add(message);
1890 var objMAN = new ManDRILLModel();
1891 objMAN.contactId = obj.OtherApplicantId;
1892 objMAN.financeid = 0;
1893 objMAN.mailcontent = _mailcontentother;
1894 objMAN.MandrillMSG = message;
1895 objMAN.IsAppContact = true;
1896 objMAN.notemsg = "";
1897 objMAN.TemplateName = name;
1898 objMAN.Status = obj.status ?? 0;
1899 _mandrillOBJ.Add(objMAN);
1900 }
1901 catch(Exception ex)
1902 {
1903 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmail", ex.Message);
1904 }
1905 }
1906 }
1907 }
1908 }
1909 else
1910 {
1911 lstContactIds.Add(objC.contactid);
1912 count++;
1913 }
1914 }
1915 _mandrillOBJ = _mandrillOBJ.FindAll(res => !lstContactIds.Contains(res.contactId));
1916 if (WebUtility.SendMailViaManDRILL(_mandrillOBJ, loggedinuserid, followUp))
1917 _chk = 1;
1918 //If all the contacts are unsubscribed
1919 if (ContactArray.Count() == count)
1920 _chk = -3;
1921
1922 }
1923 else if (toall == 1)
1924 {
1925
1926 if (allLead == null)
1927 {
1928 _chk = -2;
1929 return Json(_chk, JsonRequestBehavior.AllowGet);
1930 }
1931 if (!IsMortgageClientInclude)
1932 {
1933 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
1934 allLead = allLead.Where(x => x.brokerId == userId).AsQueryable();
1935 }
1936 // Mail To Send All Contacts as per Live Server *************************************
1937
1938 ////Get all distinct Emails****************************************************
1939 //List<MailSentStatus> _listMailStatus = new List<MailSentStatus>();
1940 //_listMailStatus = allLead.Select(c => new MailSentStatus
1941 //{
1942 // EmailId = c.email,
1943 // Status = 0
1944 //}).Distinct().ToList().Where(c => !string.IsNullOrWhiteSpace(c.EmailId)).ToList();
1945 //***************************************************************************
1946 var count = 0;
1947 List<string> emails = new List<string>();
1948 List<int> lstContactIds = new List<int>();
1949 foreach (var objMain in allLead)
1950 {
1951
1952 //if (WebUtility.UnsubscribeEmail(objMain.contactId, 3) == 3)
1953 //{
1954 // count++;
1955 // lstContactIds.Add(objMain.contactId);
1956 // continue;
1957 //}
1958 //Added for Latest Data-----------------------
1959 Q_Application QApplication = new Q_Application();
1960 var obj = QApplication.GetSingleLead(objMain.AccountId, objMain.contactId, objMain.financeid);
1961
1962
1963 //Check for unsubscribed contacts 2014-11-20
1964 if (WebUtility.UnsubscribeEmail(objMain.contactId, 3) != 3)
1965 {
1966 string _mailcontent = MailContentTemplate(
1967 body,
1968 obj.firstName,
1969 obj.lastName,
1970 (obj.followUp.HasValue ? obj.followUp.Value.ToString("dd/MM/yyyy") : "").ToString(),
1971 obj.tel,
1972 Convert.ToString(Session["telephone"] ?? ""),
1973 Convert.ToString(Session["ContactName"] ?? ""),
1974 Convert.ToString(Session["ContactEmail"] ?? ""),
1975 obj.brokerName ?? "",
1976 obj.clientname ?? "", obj.BrokerEmail ?? "", obj.PolicyNumber ?? "", obj.Lender ?? "", obj.Soliciter ?? "", obj.PrimaryContact ?? "", obj.SecondaryContact ?? "", obj.Address1 ?? "", obj.Address2 ?? "", obj.OtherDetails ?? "", obj.Title ?? "", obj.FAX ?? "", obj.Qualification ?? "", Convert.ToString(obj.contactId) ?? "");
1977
1978
1979 if (!string.IsNullOrWhiteSpace(obj.email)) // && _listMailStatus.Where(c => c.EmailId == obj.email && c.Status == 1).Count() == 0 // Apply within if condition once mail will be sent once for a single contact regardsless of multiple products
1980 {
1981 try
1982 {
1983 // check if not exists
1984 if (!emails.Contains(obj.email))
1985 {
1986 emails.Add(obj.email);
1987 //Add Notes to the note table**************************************************
1988 string HTML_TAG_PATTERN = @"<[^>]+>| ";
1989 _mailDrilEmails = new List<EmailAddress>();
1990 EmailAddress objEm = new EmailAddress();
1991 objEm.email = obj.email;
1992 objEm.name = obj.firstName + " " + obj.lastName;
1993 _mailDrilEmails.Add(objEm);
1994
1995 //Man DRILL ********************************************************************
1996 EmailMessage message = new EmailMessage();
1997 message.to = _mailDrilEmails;
1998 message.html = _mailcontent;
1999 message.from_email = obj.BrokerEmail ?? "";
2000 message.from_name = obj.brokerName ?? "";
2001 message.subject = subject;
2002 message.inline_css = true;
2003 message.signing_domain = _contentURL;
2004 message.AddHeader("X-MC-SigningDomain", _contentURL);
2005 message.AddHeader("X-MC-TrackingDomain", _contentURL);
2006 _mandrillMessage.Add(message);
2007 // Manage The ManDRILLModel - 25-07-2014
2008
2009 var objMAN = new ManDRILLModel();
2010 objMAN.contactId = obj.contactId;
2011 objMAN.financeid = obj.financeid;
2012 objMAN.mailcontent = _mailcontent;
2013 objMAN.MandrillMSG = message;
2014 objMAN.IsAppContact = false;
2015 objMAN.TemplateName = name;
2016 objMAN.Status = obj.status ?? 0;
2017 objMAN.notemsg = "Email correspondence sent : " + System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(_mailcontent, HTML_TAG_PATTERN, " "), @"\s{2,}", " ");
2018
2019 _mandrillOBJ.Add(objMAN);
2020 }
2021 }
2022 catch(Exception ex)
2023 {
2024 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmail", ex.Message);
2025 }
2026 }
2027
2028
2029 //******************************************************************************
2030
2031 // ****************************** Send Mail to other Applicant ******************************
2032 if (!string.IsNullOrWhiteSpace(obj.OtherApplicantEmail))
2033 {
2034 if (!emails.Contains(obj.OtherApplicantEmail))
2035 {
2036 // check for other application email
2037 if (!obj.email.GetString().Equals(obj.OtherApplicantEmail.GetString(), StringComparison.OrdinalIgnoreCase))
2038 {
2039 emails.Add(obj.OtherApplicantEmail);
2040 string _mailcontentother = MailContentTemplate(
2041 body,
2042 obj.OtherApplicantFname,
2043 obj.OtherApplicantSName,
2044 (obj.followUp.HasValue ? obj.followUp.Value.ToString("dd/MM/yyyy") : "").ToString(),
2045 obj.OtherApplicantMobile,
2046 Convert.ToString(Session["telephone"] ?? ""),
2047 Convert.ToString(Session["ContactName"] ?? ""),
2048 Convert.ToString(Session["ContactEmail"] ?? ""),
2049 obj.brokerName ?? "",
2050 obj.clientname ?? "", obj.BrokerEmail ?? "", obj.PolicyNumber ?? "", obj.Lender ?? "", obj.Soliciter ?? "", obj.PrimaryContact ?? "", obj.SecondaryContact ?? "", obj.Address1 ?? "", obj.Address2 ?? "", obj.OtherDetails ?? "", obj.Title ?? "", obj.FAX ?? "", obj.Qualification ?? "", Convert.ToString(obj.contactId) ?? "");
2051
2052 try
2053 {
2054 _mailDrilEmails = new List<EmailAddress>();
2055 EmailAddress objEm = new EmailAddress();
2056 objEm.email = obj.OtherApplicantEmail;
2057 objEm.name = obj.OtherApplicantFname + " " + obj.OtherApplicantSName;
2058 _mailDrilEmails.Add(objEm);
2059
2060 //Man DRILL ********************************************************************
2061 EmailMessage message = new EmailMessage();
2062 message.to = _mailDrilEmails;
2063 message.html = _mailcontent;
2064 message.from_email = obj.BrokerEmail ?? "";
2065 message.from_name = obj.brokerName ?? "";
2066 message.subject = subject;
2067 message.inline_css = true;
2068 message.signing_domain = _contentURL;
2069 message.AddHeader("X-MC-SigningDomain", _contentURL);
2070 message.AddHeader("X-MC-TrackingDomain", _contentURL);
2071 _mandrillMessage.Add(message);
2072 // Manage The ManDRILLModel - 25-07-2014
2073
2074 var objMAN = new ManDRILLModel();
2075 objMAN.contactId = obj.OtherApplicantId;
2076 objMAN.financeid = 0;
2077 objMAN.mailcontent = _mailcontent;
2078 objMAN.MandrillMSG = message;
2079 objMAN.IsAppContact = false;
2080 objMAN.notemsg = "";
2081 objMAN.TemplateName = name;
2082 objMAN.Status = obj.status ?? 0;
2083 _mandrillOBJ.Add(objMAN);
2084 }
2085 catch(Exception ex)
2086 {
2087 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmail", ex.Message);
2088 }
2089 }
2090 }
2091 }
2092 }
2093 else
2094 {
2095 lstContactIds.Add(objMain.contactId);
2096 count++;
2097 }
2098
2099 //********************************************************* Other Applicant ******************************
2100
2101 }
2102
2103 //*********************************************************END**************************************************************************
2104 _mandrillOBJ = _mandrillOBJ.FindAll(res => !lstContactIds.Contains(res.contactId));
2105 if (WebUtility.SendMailViaManDRILLForBulkEmail(_mandrillOBJ, loggedinuserid, followUp))
2106 _chk = 1;
2107 if (allLead.Count() == count)
2108 _chk = -3;
2109 }
2110 }
2111 catch(Exception ex)
2112 {
2113 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmail", ex.Message);
2114 }
2115 }
2116 else
2117 {
2118 _chk = -2;
2119 }
2120 return Json(_chk, JsonRequestBehavior.AllowGet);
2121 }
2122
2123 /// <summary>
2124 /// Display contact name and emails added on 2015-02-14
2125 /// </summary>
2126 /// <param name="templateid"></param>
2127 /// <param name="chk"></param>
2128 /// <param name="name"></param>
2129 /// <param name="EmailId"></param>
2130 /// <param name="FinanceId"></param>
2131 /// <param name="toall"></param>
2132 /// <param name="ContactArray"></param>
2133 /// <param name="subject"></param>
2134 /// <param name="body"></param>
2135 /// <param name="followUp"></param>
2136 /// <returns></returns>
2137 public JsonResult SendEmailDisConDetBef(int templateid, int chk, string name, string EmailId, int FinanceId, int toall, List<ContactMail> ContactArray, string subject, string body, bool followUp = false /* added on 28 01 2015 for followup */, bool IsMortgageClientInclude = true)
2138 {
2139
2140 int TotUnsub = 0;
2141 int Duplicate = 0;
2142 int Invalid = 0;
2143 List<SendEmailContactDetails> lstContactDetails = new List<SendEmailContactDetails>();
2144
2145 Q_Application QApplication = new Q_Application();
2146 IQueryable<ApplicationLead> allLead = null;
2147 var obj = new ApplicationJsonLead();
2148
2149 if (Session["LoggedInUserId"] == null)
2150 {
2151 return Json("SessionExpire", JsonRequestBehavior.AllowGet);
2152 }
2153 else
2154 {
2155 try {
2156 if (Session["LeadData"] != null)
2157 allLead = (IQueryable<ApplicationLead>)Session["LeadData"];
2158
2159 //Single Contact Is Selected
2160 if (toall == (int)SendEmailType.SendSingleEmail && !string.IsNullOrWhiteSpace(EmailId) && FinanceId != 0)
2161 {
2162 #region [Single Email]
2163
2164 SendEmailContactDetails objSendEmailContactDetails = new SendEmailContactDetails();
2165 if (allLead != null)
2166 {
2167 var objMain = allLead.Where(c => c.financeid == FinanceId).FirstOrDefault();
2168 obj = QApplication.GetSingleLead(objMain.AccountId, objMain.contactId, objMain.financeid);
2169 }
2170 else
2171 {
2172 var objMain = ctx.tblfinances.Where(c => c.financeid == FinanceId).FirstOrDefault();
2173 obj = QApplication.GetSingleLead(0, objMain.contact ?? 0, objMain.financeid);
2174 }
2175
2176 if (!string.IsNullOrEmpty(obj.email))
2177 {
2178 if (WebUtility.UnsubscribeEmail(obj.contactId, 3) != 3)
2179 {
2180
2181 objSendEmailContactDetails.ContactName = obj.firstName + ' ' + obj.lastName;
2182 objSendEmailContactDetails.ContactEmail = string.IsNullOrEmpty(obj.email) ? "" : obj.email;
2183 objSendEmailContactDetails.ContactOtherApplicantEmail = string.Empty;
2184
2185 lstContactDetails.Add(objSendEmailContactDetails);
2186 }
2187 else
2188 {
2189 TotUnsub = TotUnsub + 1;
2190
2191 }
2192 }
2193 else
2194 {
2195 Invalid = Invalid + 1;
2196
2197 }
2198 if (lstContactDetails != null && lstContactDetails.Count() > 0)
2199 {
2200 lstContactDetails[0].Valid = lstContactDetails.Count;
2201 lstContactDetails[0].Invalid = Invalid;
2202 lstContactDetails[0].Unsubscribe = TotUnsub;
2203 lstContactDetails[0].Duplicate = Duplicate;
2204 }
2205
2206 #endregion [Single Email]
2207 }
2208 else if (toall == (int)SendEmailType.SendMultipleEmail && ContactArray != null && ContactArray.Count() > 0)
2209 {
2210
2211 #region [Multiple Email]
2212 List<string> emails = new List<string>();
2213 lstContactDetails = new List<SendEmailContactDetails>();
2214 foreach (var objC in ContactArray)
2215 {
2216 try
2217 {
2218 FinanceId = objC.financeid;
2219 obj = new ApplicationJsonLead();
2220 if (allLead == null)
2221 {
2222 var objMain = ctx.tblfinances.Where(c => c.financeid == FinanceId).FirstOrDefault();
2223 obj = QApplication.GetSingleLead(0, objMain.contact ?? 0, objMain.financeid);
2224 }
2225 else
2226 {
2227 var objMain = allLead.Where(c => c.financeid == FinanceId).FirstOrDefault();
2228 obj = QApplication.GetSingleLead(objMain.AccountId, objMain.contactId, objMain.financeid);
2229 }
2230
2231 if (!string.IsNullOrEmpty(obj.email) || !string.IsNullOrEmpty(obj.OtherApplicantEmail))
2232 {
2233 if (!(emails.Contains(obj.email) && emails.Contains(obj.OtherApplicantEmail)))
2234 {
2235 if (WebUtility.UnsubscribeEmail(obj.contactId, 3) != 3)
2236 {
2237 SendEmailContactDetails objSendEmailContactDetails = new SendEmailContactDetails();
2238 objSendEmailContactDetails.ContactName = obj.firstName + ' ' + obj.lastName;
2239 if (!(emails.Contains(obj.email)))
2240 {
2241 if (!string.IsNullOrEmpty(obj.email))
2242 {
2243 emails.Add(obj.email);
2244 }
2245 objSendEmailContactDetails.ContactEmail = string.IsNullOrEmpty(obj.email) ? "" : obj.email;
2246 }
2247 else
2248 {
2249 objSendEmailContactDetails.ContactEmail = string.Empty;
2250 }
2251 if (!(emails.Contains(obj.OtherApplicantEmail)))
2252 {
2253 if (!string.IsNullOrEmpty(obj.OtherApplicantEmail))
2254 {
2255 emails.Add(obj.OtherApplicantEmail);
2256 }
2257 // objSendEmailContactDetails.ContactOtherApplicantEmail = string.IsNullOrEmpty(obj.OtherApplicantEmail) ? "" : obj.OtherApplicantEmail;
2258 if (obj.email.GetString().Equals(obj.OtherApplicantEmail.GetString(), StringComparison.OrdinalIgnoreCase))
2259 {
2260 objSendEmailContactDetails.ContactOtherApplicantEmail = string.Empty;
2261 }
2262 else
2263 {
2264 objSendEmailContactDetails.ContactOtherApplicantEmail = string.IsNullOrEmpty(obj.OtherApplicantEmail) ? "" : obj.OtherApplicantEmail;
2265 }
2266 }
2267 else
2268 {
2269 objSendEmailContactDetails.ContactOtherApplicantEmail = string.Empty;
2270 }
2271 if (!string.IsNullOrEmpty(objSendEmailContactDetails.ContactEmail) || !string.IsNullOrEmpty(objSendEmailContactDetails.ContactOtherApplicantEmail))
2272 {
2273 lstContactDetails.Add(objSendEmailContactDetails);
2274 }
2275 else
2276 {
2277 Duplicate = Duplicate + 1;
2278 }
2279 }
2280 else
2281 {
2282 TotUnsub = TotUnsub + 1;
2283
2284 }
2285 }
2286 else
2287 {
2288 Duplicate = Duplicate + 1;
2289 }
2290 }
2291 else
2292 {
2293 Invalid = Invalid + 1;
2294
2295 }
2296 }
2297 catch (Exception ex)
2298 {
2299 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmailDisConDetBef-SendMultipleEmail", ex.Message);
2300 }
2301 }
2302 if (lstContactDetails != null && lstContactDetails.Count() > 0)
2303 {
2304 lstContactDetails[0].Valid = lstContactDetails.Count;
2305 lstContactDetails[0].Invalid = Invalid;
2306 lstContactDetails[0].Unsubscribe = TotUnsub;
2307 lstContactDetails[0].Duplicate = Duplicate;
2308 }
2309 #endregion [Multiple Email]
2310 }
2311 else if (toall == (int)SendEmailType.SendAllEmail)
2312 {
2313 #region [Bulk Email]
2314 if (!IsMortgageClientInclude)
2315 {
2316 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2317 allLead = allLead.Where(x => x.brokerId == userId).AsQueryable();
2318 }
2319 // allLead = GetAllLeadWithSearchFilter();
2320 //if (allLead == null)
2321 //{
2322 // allLead = GetAllLeadWithSearchFilter();
2323 // Helper.ErrorLog(null, "HomeController", "SendEmailDisConDetBef-Bullkemailleadnull", Convert.ToString(allLead.Count()));
2324 //}
2325 if (allLead != null)
2326 {
2327 Helper.ErrorLog(null, "HomeController", "SendEmailDisConDetBef-Bullkemailleadnotnull", allLead.Count().ToString());
2328 List<string> emails = new List<string>();
2329 List<int> lstContactIds = new List<int>();
2330 foreach (var objMain in allLead)
2331 {
2332
2333 try
2334 {
2335 if (!string.IsNullOrEmpty(objMain.email) || !string.IsNullOrEmpty(objMain.OtherApplicantEmail))
2336 {
2337 if (!(emails.Contains(objMain.email) && emails.Contains(objMain.OtherApplicantEmail)))
2338 {
2339 if (WebUtility.UnsubscribeEmail(objMain.contactId, 3) != 3)
2340 {
2341 SendEmailContactDetails objSendEmailContactDetails = new SendEmailContactDetails();
2342 objSendEmailContactDetails.ContactName = objMain.firstName + ' ' + objMain.lastName;
2343
2344 if (!(emails.Contains(objMain.email)))
2345 {
2346 if (!string.IsNullOrEmpty(objMain.email))
2347 {
2348 emails.Add(objMain.email);
2349 }
2350 objSendEmailContactDetails.ContactEmail = string.IsNullOrEmpty(objMain.email) ? "" : objMain.email;
2351 }
2352 else
2353 {
2354
2355 objSendEmailContactDetails.ContactEmail = string.Empty;
2356 }
2357
2358
2359 if (!(emails.Contains(objMain.OtherApplicantEmail)))
2360 {
2361 if (!string.IsNullOrEmpty(objMain.OtherApplicantEmail))
2362 {
2363 emails.Add(objMain.OtherApplicantEmail);
2364 }
2365 // objSendEmailContactDetails.ContactOtherApplicantEmail = string.IsNullOrEmpty(objMain.OtherApplicantEmail) ? "" : objMain.OtherApplicantEmail;
2366 if (objMain.email.GetString().Equals(objMain.OtherApplicantEmail.GetString(), StringComparison.OrdinalIgnoreCase))
2367 {
2368
2369 objSendEmailContactDetails.ContactOtherApplicantEmail = string.Empty;
2370 }
2371 else
2372 {
2373
2374 objSendEmailContactDetails.ContactOtherApplicantEmail = string.IsNullOrEmpty(objMain.OtherApplicantEmail) ? "" : objMain.OtherApplicantEmail;
2375 }
2376 }
2377 else
2378 {
2379 objSendEmailContactDetails.ContactOtherApplicantEmail = string.Empty;
2380 }
2381
2382 if (!string.IsNullOrEmpty(objSendEmailContactDetails.ContactEmail) || !string.IsNullOrEmpty(objSendEmailContactDetails.ContactOtherApplicantEmail))
2383 {
2384 lstContactDetails.Add(objSendEmailContactDetails);
2385 }
2386 else
2387 {
2388 Duplicate = Duplicate + 1;
2389 }
2390
2391 }
2392 else
2393 {
2394 TotUnsub = TotUnsub + 1;
2395 }
2396 }
2397 else
2398 {
2399 Duplicate = Duplicate + 1;
2400 }
2401 }
2402 else
2403 {
2404 Invalid = Invalid + 1;
2405 }
2406 }
2407 catch (Exception ex)
2408 {
2409 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmailDisConDetBef-BulkEmail", ex.Message);
2410 }
2411
2412 }
2413
2414
2415 if (lstContactDetails != null && lstContactDetails.Count() > 0)
2416 {
2417 lstContactDetails[0].Valid = lstContactDetails.Count;
2418 lstContactDetails[0].Invalid = Invalid;
2419 lstContactDetails[0].Unsubscribe = TotUnsub;
2420 lstContactDetails[0].Duplicate = Duplicate;
2421 }
2422
2423 }
2424 else
2425 {
2426 Helper.ErrorLog(null, "HomeController", "SendEmailDisConDetBef-Bullkemail", "Bullk email allLead null");
2427 }
2428 #endregion [Bulk Email]
2429 }
2430 }
2431 catch (Exception ex)
2432 {
2433 Helper.ErrorLog(ex.InnerException, "HomeController", "SendEmailDisConDetBef-Main Else", ex.Message);
2434 }
2435
2436 }
2437
2438 return Json(lstContactDetails, JsonRequestBehavior.AllowGet);
2439 }
2440
2441 private IQueryable<ApplicationLead> GetAllLeadWithSearchFilter()
2442 {
2443 IQueryable<ApplicationLead> allLead = null;
2444 Q_Application qApplication = new Q_Application();
2445 Filters filters = (Filters)Session["SearchFilters"];
2446 int userid = Convert.ToInt32(Session["LoggedInUserAccountId"]);
2447 int loggedinuser = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2448 List<listobject> contactlistsnew = new List<listobject>();
2449 List<tblfinancestatu> contactlists = new List<tblfinancestatu>();
2450 bool isUser = qApplication.IsUser(loggedinuser);
2451 int isHideNotRequire = 1;
2452 string Search = "";
2453 if (Session["Search"] != null)
2454 {
2455 Search = Convert.ToString(Session["Search"]).Trim();
2456 }
2457 string _brIds =string.Empty, _status= string.Empty, _lender= string.Empty, _solicitor = string.Empty;
2458
2459
2460 if (filters != null)
2461 {
2462 if (!string.IsNullOrWhiteSpace(filters.brokeridcsv))
2463 {
2464 _brIds = filters.brokeridcsv.TrimEnd(',');
2465
2466 }
2467 if (!string.IsNullOrWhiteSpace(filters.status))
2468 {
2469 _status = filters.status.TrimEnd(',');
2470
2471 }
2472 if (!string.IsNullOrWhiteSpace(filters.Lender))
2473 {
2474 _lender = filters.Lender.Trim();
2475
2476 }
2477 if (!string.IsNullOrWhiteSpace(filters.Soliciter))
2478 {
2479 _solicitor = filters.Soliciter.Trim();
2480
2481 }
2482
2483 isHideNotRequire = filters.isHideNotRequire == true ? 1 : 0;
2484 }
2485
2486 List<StatusCount> _listStatusCount = new List<StatusCount>();
2487 if (filters != null)
2488 {
2489 allLead = qApplication.GetAllLead(out _listStatusCount, userid, loggedinuser, filters.appid, Search, filters.clientid, _brIds, _status, _lender, _solicitor, isHideNotRequire);
2490 }
2491 else
2492 {
2493 if (filters == null)
2494 {
2495
2496 filters = new Filters();
2497 filters.appid = 1;
2498 filters.brokerid = 0;
2499 filters.brokeridcsv = "";
2500 filters.clientid = 0;
2501 filters.isHideNotRequire = true;
2502 filters.Lender = "";
2503 filters.Soliciter = "";
2504 filters.status = "2,3,4,5,6,7";
2505
2506 allLead = qApplication.GetAllLead(out _listStatusCount, userid, loggedinuser, filters.appid, Search, filters.clientid, _brIds, _status, _lender, _solicitor, isHideNotRequire);
2507 }
2508 else
2509 {
2510 allLead = (IQueryable<ApplicationLead>)Session["LeadData"];
2511 }
2512 }
2513 if (isHideNotRequire == 1)
2514 {
2515 allLead = allLead.Where(c => c.status != 8 && c.status != 14 && c.status != 20 && c.status != 26 && c.status != 32);
2516 }
2517 return allLead;
2518 }
2519
2520 /// <summary>
2521 /// Add update method
2522 /// </summary>
2523 /// <param name="templateid"></param>
2524 /// <param name="name"></param>
2525 /// <param name="subject"></param>
2526 /// <param name="body"></param>
2527 /// <returns></returns>
2528 [App_Start.SessionTimeOutActionFilter]
2529 public int AddUpdate(int templateid, string name, string subject, string body)
2530 {
2531 int chk = 0;
2532 string _connectionstring = Convert.ToString(ConfigurationManager.ConnectionStrings["ConString1"]);
2533 try
2534 {
2535 if (Session["LoggedInUserId"] == null)
2536 {
2537 chk = -2;
2538 }
2539 else
2540 {
2541 var _userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2542 var _accountId = Convert.ToInt32(Session["LoggedInUserAccountId"] ?? "0");
2543
2544 if (templateid > 0)
2545 {
2546 using (SqlConnection con = new SqlConnection(_connectionstring))
2547 {
2548 using (SqlCommand cmd = new SqlCommand("MailTemplateUpdate", con))
2549 {
2550 cmd.CommandType = CommandType.StoredProcedure;
2551 cmd.Parameters.AddWithValue("@UserId", _userId);
2552 cmd.Parameters.AddWithValue("@TemplateId", templateid);
2553 cmd.Parameters.AddWithValue("@TemplateName", name);
2554 cmd.Parameters.AddWithValue("@Subject", subject);
2555 cmd.Parameters.AddWithValue("@Templates", body);
2556 cmd.Parameters.Add("@Chk", SqlDbType.Int);
2557 cmd.Parameters["@Chk"].Direction = ParameterDirection.Output;
2558 con.Open();
2559 cmd.ExecuteNonQuery();
2560 chk = Convert.ToInt32(cmd.Parameters["@Chk"].SqlValue.ToString());
2561 con.Close();
2562 con.Dispose();
2563 }
2564 }
2565
2566 }
2567 else
2568 {
2569 using (SqlConnection con = new SqlConnection(_connectionstring))
2570 {
2571 using (SqlCommand cmd = new SqlCommand("MailTemplateAdd", con))
2572 {
2573 cmd.CommandType = CommandType.StoredProcedure;
2574 cmd.Parameters.AddWithValue("@UserId", _userId);
2575 cmd.Parameters.AddWithValue("@AccountId", _accountId);
2576 cmd.Parameters.AddWithValue("@TemplateName", name);
2577 cmd.Parameters.AddWithValue("@Subject", subject);
2578 cmd.Parameters.AddWithValue("@Templates", body);
2579 cmd.Parameters.Add("@TemplateId", SqlDbType.Int);
2580 cmd.Parameters["@TemplateId"].Direction = ParameterDirection.Output;
2581 con.Open();
2582 cmd.ExecuteNonQuery();
2583 chk = Convert.ToInt32(cmd.Parameters["@TemplateId"].SqlValue.ToString());
2584 con.Close();
2585 con.Dispose();
2586 }
2587 }
2588 }
2589
2590 }
2591 }
2592 catch(Exception ex)
2593 {
2594 Helper.ErrorLog(ex.InnerException, "HomeController", "AddUpdate", ex.Message);
2595
2596 }
2597 return chk;
2598 }
2599
2600 /// <summary>
2601 /// Get template details
2602 /// </summary>
2603 /// <returns></returns>
2604 [App_Start.SessionTimeOutActionFilter]
2605 public ActionResult GetTemplaes()
2606 {
2607 var templates = new List<MailTemplate>();
2608 int chk = 0;
2609 try
2610 {
2611 if (Session["LoggedInUserId"] != null)
2612 {
2613 chk = 1;
2614 var _userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2615 SqlParameter[] Param = new SqlParameter[1];
2616 Param[0] = new SqlParameter("@UserId", _userId);
2617 DataTable dt = SqlHelper.ExecuteDatatable(CommandType.StoredProcedure, "MailTemplateGet", Param);
2618
2619 templates = (from DataRow row in dt.Rows
2620 select new MailTemplate
2621 {
2622 TemplateId = Convert.ToInt32(((row["TemplateId"] == DBNull.Value || row["TemplateId"] == null) ? "0" : row["TemplateId"])),
2623 UserId = Convert.ToInt32(((row["UserId"] == DBNull.Value || row["UserId"] == null) ? "0" : row["UserId"])),
2624 AccountId = Convert.ToInt32(((row["AccountId"] == DBNull.Value || row["AccountId"] == null) ? "0" : row["AccountId"])),
2625 TemplateName = ((row["TemplateName"] == DBNull.Value || row["TemplateName"] == null) ? " " : row["TemplateName"]).ToString(),
2626 Subject = ((row["Subject"] == DBNull.Value || row["Subject"] == null) ? " " : row["Subject"]).ToString(),
2627 Templates = ((row["Templates"] == DBNull.Value || row["Templates"] == null) ? " " : row["Templates"]).ToString(),
2628 AddDate = (row["AddDate"] == DBNull.Value || row["AddDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["AddDate"]),
2629 UpdateDate = (row["UpdateDate"] == DBNull.Value || row["UpdateDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["UpdateDate"]),
2630
2631 }).OrderByDescending(c => c.TemplateId).ToList();
2632 }
2633 else
2634 {
2635 chk = -2;
2636 }
2637 }
2638 catch(Exception ex)
2639 {
2640 Helper.ErrorLog(ex.InnerException, "HomeController", "GetTemplates", ex.Message);
2641 }
2642
2643 return Json(new { MailTemplates = templates, chk = chk }, JsonRequestBehavior.AllowGet);
2644 }
2645
2646 [App_Start.SessionTimeOutActionFilter]
2647 public ActionResult GetTemplaesById(int templateid)
2648 {
2649 var template = new MailTemplate();
2650 int chk = 0;
2651 try
2652 {
2653 if (Session["LoggedInUserId"] != null)
2654 {
2655 chk = 1;
2656 var _userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2657 SqlParameter[] Param = new SqlParameter[1];
2658 Param[0] = new SqlParameter("@TemplateId", templateid);
2659 DataTable dt = SqlHelper.ExecuteDatatable(CommandType.StoredProcedure, "MailTemplateGetById", Param);
2660
2661 template = (from DataRow row in dt.Rows
2662 select new MailTemplate
2663 {
2664 TemplateId = Convert.ToInt32(((row["TemplateId"] == DBNull.Value || row["TemplateId"] == null) ? "0" : row["TemplateId"])),
2665 UserId = Convert.ToInt32(((row["UserId"] == DBNull.Value || row["UserId"] == null) ? "0" : row["UserId"])),
2666 AccountId = Convert.ToInt32(((row["AccountId"] == DBNull.Value || row["AccountId"] == null) ? "0" : row["AccountId"])),
2667 TemplateName = ((row["TemplateName"] == DBNull.Value || row["TemplateName"] == null) ? " " : row["TemplateName"]).ToString(),
2668 Subject = ((row["Subject"] == DBNull.Value || row["Subject"] == null) ? " " : row["Subject"]).ToString(),
2669 Templates = ((row["Templates"] == DBNull.Value || row["Templates"] == null) ? " " : row["Templates"]).ToString(),
2670 AddDate = (row["AddDate"] == DBNull.Value || row["AddDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["AddDate"]),
2671 UpdateDate = (row["UpdateDate"] == DBNull.Value || row["UpdateDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["UpdateDate"]),
2672 }).OrderByDescending(c => c.TemplateId).FirstOrDefault();
2673 }
2674 else
2675 {
2676 chk = 2;
2677 }
2678 }
2679 catch(Exception ex)
2680 {
2681 Helper.ErrorLog(ex.InnerException, "HomeController", "GetTemplatesById", ex.Message);
2682 }
2683 return Json(new { MailTemplate = template, chk = chk }, JsonRequestBehavior.AllowGet);
2684 }
2685
2686 [App_Start.SessionTimeOutActionFilter]
2687 public ActionResult DeleteTemplae(int templateid)
2688 {
2689 string _connectionstring = Convert.ToString(ConfigurationManager.ConnectionStrings["ConString1"]);
2690 int chk = 0;
2691 if (Session["LoggedInUserId"] != null)
2692 {
2693 using (SqlConnection con = new SqlConnection(_connectionstring))
2694 {
2695 using (SqlCommand cmd = new SqlCommand("MailTemplateDelete", con))
2696 {
2697 cmd.CommandType = CommandType.StoredProcedure;
2698 cmd.Parameters.AddWithValue("@TemplateId", templateid);
2699 con.Open();
2700 chk = cmd.ExecuteNonQuery();
2701 con.Close();
2702 con.Dispose();
2703 }
2704 }
2705 }
2706 else
2707 {
2708 chk = -2;
2709 }
2710 return Json(chk, JsonRequestBehavior.AllowGet);
2711 }
2712
2713
2714 public static string MailContentTemplate(string mailcontent, string FName, string LName, string followupdate, string contacttel, string usertel, string username, string useremail, string brokername, string CompanyName, string BrokerEmail, string PolicyNumber, string ProviderName, string SolicitorName, string PrimaryContact, string SecondaryContact, string Address1, string Address2, string OtherDetails, string Title, string FAX, string Qualification, string ContactId, string mortgage_amount = "",
2715 string mortgage_propertyvalue = "", string mortgage_propertyaddress = "", string adviserImage = "")
2716 {
2717 StringBuilder _tempate = new StringBuilder();
2718 try
2719 {
2720 string siteUrl = Convert.ToString(ConfigurationManager.AppSettings["SecureURL"] ?? "http://secure.occfinance.com"); _tempate.Append(mailcontent);
2721 _tempate = _tempate
2722 .Replace("*|FNAME|*", FName)
2723 .Replace("*|LNAME|*", LName)
2724 .Replace("*|CONTTEL|*", contacttel)
2725 .Replace("*|UNAME|*", username)
2726 .Replace("*|UEMAIL|*", useremail)
2727 .Replace("*|UTEL|*", usertel)
2728 .Replace("*|FDATE|*", followupdate)
2729 .Replace("*|ADVISERN|*", brokername)
2730 .Replace("*|ADVISERQ|*", Qualification)
2731 .Replace("*|CNAME|*", CompanyName)
2732 .Replace("*|ADVISEREMA|*", BrokerEmail)
2733 .Replace("*|PNUM|*", PolicyNumber)
2734 .Replace("*|PRVNAME|*", ProviderName)
2735 .Replace("*|SNAME|*", SolicitorName)
2736 .Replace("*|ADVISERTEL|*", PrimaryContact)
2737 .Replace("*|ADVISERMOB|*", SecondaryContact)
2738 .Replace("*|ADVSRAD1|*", Address1)
2739 .Replace("*|ADVSRAD2|*", Address2)
2740 .Replace("*|ADVSRODL|*", OtherDetails)
2741 .Replace("*|ADVISERFAX|*", FAX)
2742 .Replace("*|ADVISERTTL|*", Title)
2743 .Replace("*|DISCLAIMER|*", "")
2744 .Replace("*|COMPANYURL|*", "")
2745 .Replace("*|MC:SUBJECT|*", "")
2746 .Replace("*|MSGBODY|*", "")
2747 .Replace("*|UNSUB|*", siteUrl + "/Home/UnsubscribeEmails?contactId=" + ContactId + "&type=1")
2748 //NEWLY ADDED
2749 // .Replace("*|WORKINGDAYS|*", "") //WORKING [editable]
2750 .Replace("*|PROPERTYADDRESS|*", mortgage_propertyaddress) //PROPERTY ADDRESS
2751 .Replace("*|PROPERTYVALUE|*", mortgage_propertyvalue) //PROPERTY VALUE
2752 .Replace("*|MORTGAGE|*", mortgage_amount) //MORTGAGE
2753 .Replace("*|ADVISERIMAGE|*",adviserImage); //adviser image
2754
2755 }
2756 catch (Exception ex)
2757 {
2758 Helper.ErrorLog(ex.InnerException, "HomeController", "MailContentTemplate", ex.Message);
2759 }
2760
2761 return _tempate.ToString();
2762 }
2763
2764
2765 [App_Start.SessionTimeOutActionFilter]
2766 [ValidateInput(false)]
2767 public ActionResult AddNote(string notes, int assignedTo = 0)
2768 {
2769 int chk = 0;
2770 string _connectionstring = Convert.ToString(ConfigurationManager.ConnectionStrings["ConString1"]);
2771 try
2772 {
2773 if (Session["LoggedInUserId"] == null)
2774 {
2775 chk = -2;
2776 }
2777 else
2778 {
2779 var _userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2780 var _accountId = Convert.ToInt32(Session["LoggedInUserAccountId"] ?? "0");
2781
2782 if (!string.IsNullOrWhiteSpace(notes))
2783 {
2784 using (SqlConnection con = new SqlConnection(_connectionstring))
2785 {
2786 using (SqlCommand cmd = new SqlCommand("tblglobalnotesADD", con))
2787 {
2788 cmd.CommandType = CommandType.StoredProcedure;
2789 cmd.Parameters.AddWithValue("@UserId", _userId);
2790 cmd.Parameters.AddWithValue("@AccountId", _accountId);
2791 cmd.Parameters.AddWithValue("@Notes", notes);
2792 cmd.Parameters.AddWithValue("@PerMission", 1);
2793 cmd.Parameters.AddWithValue("@IsDelete", 0);
2794 cmd.Parameters.AddWithValue("@IsActive", 1);
2795 cmd.Parameters.AddWithValue("@AssignedTo", assignedTo);
2796 cmd.Parameters.AddWithValue("@IsCompleted", 0);
2797 cmd.Parameters.Add("@NoteId", SqlDbType.BigInt);
2798 cmd.Parameters["@NoteId"].Direction = ParameterDirection.Output;
2799 con.Open();
2800 cmd.ExecuteNonQuery();
2801 chk = Convert.ToInt32(cmd.Parameters["@NoteId"].SqlValue.ToString());
2802 con.Close();
2803 con.Dispose();
2804 }
2805 }
2806 }
2807 else
2808 {
2809 chk = -3;
2810 }
2811
2812 }
2813 }
2814 catch(Exception ex)
2815 {
2816 Helper.ErrorLog(ex.InnerException, "HomeController", "AddNote", ex.Message);
2817 }
2818 return Json(chk, JsonRequestBehavior.AllowGet);
2819 }
2820
2821 [App_Start.SessionTimeOutActionFilter]
2822 public ActionResult CompleteNote(int Noteid, string assignedByName, string assignedToName)
2823 {
2824 string _connectionstring = Convert.ToString(ConfigurationManager.ConnectionStrings["ConString1"]);
2825 int chk = 0;
2826 int loggeinUserId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2827 try
2828 {
2829 if (Session["LoggedInUserId"] != null)
2830 {
2831 var userNameWithNote = (from g in ctx.tblglobalnotes
2832 join u in ctx.tblusers
2833 on g.UserId equals u.userid
2834 where g.NoteId == Noteid
2835 select new
2836 {
2837 u.username,
2838 g.Notes,
2839 u.userid
2840 }
2841 ).FirstOrDefault();
2842
2843 using (SqlConnection con = new SqlConnection(_connectionstring))
2844 {
2845 using (SqlCommand cmd = new SqlCommand("tblglobalnotesComplete", con))
2846 {
2847 cmd.CommandType = CommandType.StoredProcedure;
2848 cmd.Parameters.AddWithValue("@NoteId", Noteid);
2849 con.Open();
2850 chk = cmd.ExecuteNonQuery();
2851 con.Close();
2852 con.Dispose();
2853 }
2854 }
2855 bool _chkmail = false;
2856 try
2857 {
2858 if (chk > 0)
2859 {
2860 Qclient.SendNotificationEmailCompleteNotes(assignedByName, assignedToName, userNameWithNote.Notes, userNameWithNote.username, loggeinUserId, userNameWithNote.userid);
2861
2862 }
2863 }
2864 catch(Exception ex)
2865 {
2866 Helper.ErrorLog(ex.InnerException, "HomeController", "CompleteNote", ex.Message);
2867 }
2868
2869 }
2870 else
2871 {
2872 chk = -2;
2873 }
2874 }
2875 catch(Exception ex)
2876 {
2877 Helper.ErrorLog(ex.InnerException, "HomeController", "CompleteNote", ex.Message);
2878 }
2879 return Json(chk, JsonRequestBehavior.AllowGet);
2880 }
2881
2882 [App_Start.SessionTimeOutActionFilter]
2883 public ActionResult DeleteNote(int Noteid)
2884 {
2885 string _connectionstring = Convert.ToString(ConfigurationManager.ConnectionStrings["ConString1"]);
2886 int chk = 0;
2887 try
2888 {
2889 if (Session["LoggedInUserId"] != null)
2890 {
2891 using (SqlConnection con = new SqlConnection(_connectionstring))
2892 {
2893 using (SqlCommand cmd = new SqlCommand("tblglobalnotesDELETE", con))
2894 {
2895 cmd.CommandType = CommandType.StoredProcedure;
2896 cmd.Parameters.AddWithValue("@NoteId", Noteid);
2897 con.Open();
2898 chk = cmd.ExecuteNonQuery();
2899 con.Close();
2900 con.Dispose();
2901 }
2902 }
2903 }
2904 else
2905 {
2906 chk = -2;
2907 }
2908 }
2909 catch(Exception ex)
2910 {
2911 Helper.ErrorLog(ex.InnerException, "HomeController", "DeleteNote", ex.Message);
2912 }
2913 return Json(chk, JsonRequestBehavior.AllowGet);
2914 }
2915
2916 [App_Start.SessionTimeOutActionFilter]
2917 public ActionResult GetNotes(int isall = 0, int Limit = 0, string SearchTest = "")
2918 {
2919
2920 var limit = Convert.ToInt32(ConfigurationManager.AppSettings["NoteLimit"] ?? "0");
2921
2922 if (Limit > limit && isall == 2)
2923 limit = Limit; // When click on more button it will load 10 more records
2924
2925 if (isall == 1)
2926 limit = 0;
2927
2928 var notes = new List<GlobalNnotes>();
2929 int chk = 0;
2930 var _userId = 0;
2931 var TotalNote = 0;
2932 try
2933 {
2934 if (Session["LoggedInUserId"] != null)
2935 {
2936 chk = 1;
2937 _userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
2938 var _accountId = Convert.ToInt32(Session["LoggedInUserAccountId"] ?? "0");
2939 SqlParameter[] Param = new SqlParameter[4];
2940 Param[0] = new SqlParameter("@UserId", _userId);
2941 Param[1] = new SqlParameter("@Limit", limit);
2942 Param[2] = new SqlParameter("@AccountId", _accountId);
2943
2944 if (!string.IsNullOrWhiteSpace(SearchTest))
2945 Param[3] = new SqlParameter("@SearchText", SearchTest);
2946
2947 DataSet ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "tblglobalnotesGETNOTES", Param);
2948 if (ds.Tables.Count > 0)
2949 {
2950 if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
2951 {
2952 notes = (from DataRow row in ds.Tables[0].Rows
2953 select new GlobalNnotes
2954 {
2955 AssignedUserId = Convert.ToInt32(((row["AssignedTo"] == DBNull.Value || row["AssignedTo"] == null) ? "0" : row["AssignedTo"])),
2956 NoteId = Convert.ToInt64(((row["NoteId"] == DBNull.Value || row["NoteId"] == null) ? "0" : row["NoteId"])),
2957 UserId = Convert.ToInt32(((row["UserId"] == DBNull.Value || row["UserId"] == null) ? "0" : row["UserId"])),
2958 AccountId = Convert.ToInt32(((row["AccountId"] == DBNull.Value || row["AccountId"] == null) ? "0" : row["AccountId"])),
2959 Notes = ((row["Notes"] == DBNull.Value || row["Notes"] == null) ? " " : row["Notes"]).ToString(),
2960 BrokerName = ((row["BrokerName"] == DBNull.Value || row["BrokerName"] == null) ? " " : row["BrokerName"]).ToString(),
2961 PerMission = Convert.ToInt32(((row["PerMission"] == DBNull.Value || row["PerMission"] == null) ? "0" : row["PerMission"])),
2962 IsActive = Convert.ToBoolean(((row["IsActive"] == DBNull.Value || row["IsActive"] == null) ? "0" : row["IsActive"])),
2963 AddDate = (row["AddDate"] == DBNull.Value || row["AddDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["AddDate"]),
2964 UpdateDate = (row["UpdateDate"] == DBNull.Value || row["UpdateDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["UpdateDate"]),
2965 JSonAdddate = ((row["AddDate"] == DBNull.Value || row["AddDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["AddDate"])) != (DateTime?)null ? Convert.ToDateTime(row["AddDate"]).ToString("dd-MMMM-yyyy HH:MM:ss") : "",
2966 JSonUpdatedate = ((row["UpdateDate"] == DBNull.Value || row["UpdateDate"] == null) ? (DateTime?)null : Convert.ToDateTime(row["UpdateDate"])) != (DateTime?)null ? Convert.ToDateTime(row["UpdateDate"]).ToString("dd-MMMM-yyyy HH:MM:ss ") : ""
2967
2968 }).OrderByDescending(c => c.AddDate).ToList();
2969 }
2970 notes.ForEach(x => x.AssignedUserName = (ctx.tblusers.Where(b => b.userid == ((x.AssignedUserId ?? 0) == 0 ? x.UserId : x.AssignedUserId)).FirstOrDefault().brokername ?? ""));
2971 notes.ForEach(x => x.BrokerName = (ctx.tblusers.Where(b => b.userid == x.UserId).FirstOrDefault().brokername ?? ""));
2972
2973 if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
2974 {
2975 TotalNote = Convert.ToInt32(((ds.Tables[1].Rows[0]["TotalNote"] == DBNull.Value || ds.Tables[1].Rows[0]["TotalNote"] == null) ? "0" : ds.Tables[1].Rows[0]["TotalNote"]));
2976 }
2977
2978 }
2979 }
2980 else
2981 {
2982 chk = -2;
2983 }
2984 }
2985 catch(Exception ex)
2986 {
2987 Helper.ErrorLog(ex.InnerException, "HomeController", "GetNotes", ex.Message);
2988 }
2989 return Json(new { GlobalNnotes = notes, LoggedInUserId = _userId, TotalNote = TotalNote, chk = chk }, JsonRequestBehavior.AllowGet);
2990 }
2991
2992
2993 public class MailSentStatus
2994 {
2995 public string EmailId { get; set; }
2996 public int Status { get; set; }
2997 }
2998 public class ContactMail
2999 {
3000 public int financeid { get; set; }
3001 public int contactid { get; set; }
3002 }
3003 public ActionResult Error()
3004 {
3005 if (Session["LoggedInUserId"] == null)
3006 {
3007 return RedirectToAction("index", "home");
3008 }
3009 else
3010 {
3011 return View();
3012 }
3013 }
3014
3015 public ActionResult scripterror()
3016 {
3017 if (Session["LoggedInUserId"] == null)
3018 {
3019 return RedirectToAction("index", "home");
3020 }
3021 else
3022 {
3023 return View();
3024 }
3025 }
3026
3027 [App_Start.SessionTimeOutActionFilter]
3028 public ActionResult DeleteFile(string fileName, string IndividualFolderName)
3029 {
3030 int chk = 0;
3031 int noimgcount = 1;
3032 try
3033 {
3034 if (Session["LoggedInUserId"] == null)
3035 {
3036 chk = -2;
3037 }
3038 else
3039 {
3040
3041 string subPath = ConfigurationManager.AppSettings["MailAttachment"] + (IndividualFolderName ?? "") + "/";
3042 if (System.IO.File.Exists(Server.MapPath(subPath) + fileName))
3043 {
3044 System.IO.File.Delete(Server.MapPath(subPath) + fileName);
3045 if (!Directory.EnumerateFiles(Server.MapPath(subPath)).Any())
3046 {
3047 noimgcount = 0;
3048 }
3049 chk = 1;
3050 }
3051
3052 }
3053 }
3054 catch(Exception ex)
3055 {
3056 Helper.ErrorLog(ex.InnerException, "HomeController", "DeleteFile", ex.Message);
3057 }
3058 return Json(new { chk = chk, noimgcount = noimgcount }, JsonRequestBehavior.AllowGet);
3059 }
3060
3061 [App_Start.SessionTimeOutActionFilter]
3062 public ActionResult GetTemplatesFromMailChimp()
3063 {
3064
3065
3066 try
3067 {
3068 if (Session["LoggedInUserId"] != null)
3069 {
3070 // Pass the API key on the constructor:
3071 MailChimpManager mc = new MailChimpManager(ConfigurationManager.AppSettings["MailChimpApikey"]);
3072 // Next, make any API call you'd like:
3073 MailChimp.Templates.TemplateTypes _type = new MailChimp.Templates.TemplateTypes();
3074 _type.Base = false;
3075 _type.Gallery = false;
3076 _type.User = true;
3077 MailChimp.Templates.TemplateFilters _filters = new MailChimp.Templates.TemplateFilters();
3078 _filters.Category = string.Empty;
3079 _filters.FolderID = string.Empty;
3080 _filters.IncludeInactive = false;
3081 _filters.IncludeDragAndDrop = true;
3082 _filters.IncludeInactive = false;
3083
3084 var xx = mc.GetTemplates(_type, _filters);
3085 return Json(mc.GetTemplates(_type, _filters), JsonRequestBehavior.AllowGet);
3086 }
3087 else
3088 {
3089 return Json(-2, JsonRequestBehavior.AllowGet);
3090
3091 }
3092 }
3093 catch(Exception ex)
3094 {
3095 Helper.ErrorLog(ex.InnerException, "HomeController", "GetTemplatesFromMailChimp", ex.Message);
3096 return Json(null, JsonRequestBehavior.AllowGet);
3097 }
3098
3099 }
3100
3101
3102 [App_Start.SessionTimeOutActionFilter]
3103 public ActionResult GetTemplatesByIdFromMailChimp(int templateid, int financeid)
3104 {
3105
3106 try
3107 {
3108 if (Session["LoggedInUserId"] != null)
3109 {
3110 var _userName = Convert.ToString(Session["ContactName"] ?? "");
3111 var _usertel = Convert.ToString(Session["telephone"] ?? "");
3112 var _useremail = Convert.ToString(Session["ContactEmail"] ?? "");
3113
3114 // Pass the API key on the constructor:
3115 MailChimpManager mc = new MailChimpManager(ConfigurationManager.AppSettings["MailChimpApikey"]);
3116
3117 var _templateInfo = mc.GetTemplateInformation(templateid);
3118 //mc.GetTemplateInformation(templateid);
3119
3120 IQueryable<ApplicationLead> allLead = null;
3121 if (Session["LeadData"] != null)
3122 allLead = (IQueryable<ApplicationLead>)Session["LeadData"];
3123
3124 Q_Application QApplication = new Q_Application();
3125 var obj = new ApplicationJsonLead();
3126 if (allLead == null)
3127 {
3128 var objMain = ctx.tblfinances.Where(c => c.financeid == financeid).FirstOrDefault();
3129 obj = QApplication.GetSingleLead(0, objMain.contact ?? 0, objMain.financeid);
3130 }
3131 else
3132 {
3133 var objMain = allLead.Where(c => c.financeid == financeid).FirstOrDefault();
3134 obj = QApplication.GetSingleLead(objMain.AccountId, objMain.contactId, objMain.financeid);
3135 }
3136
3137 if (obj != null)
3138 {
3139 string _mailcontent = MailContentTemplate(_templateInfo != null ? _templateInfo.Source : "",
3140 obj.firstName,
3141 obj.lastName,
3142 (obj.followUp.HasValue ? obj.followUp.Value.ToString("dd/MM/yyyy") : "").ToString(),
3143 obj.tel, _usertel, _userName, _useremail,
3144 obj.brokerName ?? "",
3145 obj.clientname ?? "", obj.BrokerEmail ?? "", obj.PolicyNumber ?? "", obj.Lender ?? "", obj.Soliciter ?? "", obj.PrimaryContact ?? "", obj.SecondaryContact ?? "", obj.Address1 ?? "", obj.Address2 ?? "", obj.OtherDetails ?? "", obj.Title ?? "", obj.FAX ?? "", obj.Qualification ?? "", Convert.ToString(obj.contactId) ?? "");
3146 return Json(new { ReplacedContent = _mailcontent, OriginalContent = _templateInfo != null ? _templateInfo.Source.Replace("*|MC:SUBJECT|*", "") : "", chk = 1 }, JsonRequestBehavior.AllowGet);
3147 }
3148 else
3149 {
3150 return Json(new { ReplacedContent = "", OriginalContent = _templateInfo != null ? _templateInfo.Source.Replace("*|MC:SUBJECT|*", "") : "", chk = 1 }, JsonRequestBehavior.AllowGet);
3151 }
3152
3153 }
3154 else
3155 {
3156 return Json(new { ReplacedContent = "", OriginalContent = "", chk = 2 }, JsonRequestBehavior.AllowGet);
3157 }
3158 }
3159 catch(Exception ex)
3160 {
3161 Helper.ErrorLog(ex.InnerException, "HomeController", "GetTemplatesByIdFromMailChimp", ex.Message);
3162 return Json(null, JsonRequestBehavior.AllowGet);
3163 }
3164
3165 }
3166
3167
3168 /*****************************************************
3169 Last updated on 09/10/2014 by Anupam
3170
3171 Summary : new querystrig parameters added for unicode , concatenation and sender id (from address).
3172 signature added for messege.
3173 ******************************************************/
3174 [ValidateInput(false)]
3175 [App_Start.SessionTimeOutActionFilter]
3176 public ActionResult SendTextMsg(string MobileNumbers, string Message, int ContactId = 0)
3177 {
3178 int _chk = 0;
3179 if (Session["LoggedInUserId"] != null)
3180 {
3181 var _userName = Convert.ToString(Session["ContactName"] ?? "");
3182 var _usertel = Convert.ToString(Session["PrimaryContact"] ?? "");
3183
3184 try
3185 {
3186 int _maxlenth = Convert.ToInt32(ConfigurationManager.AppSettings["MaxTextMsgLength"] ?? "160");
3187
3188 LastNoteWithDetails _detail = new LastNoteWithDetails();
3189 SqlParameter[] Param = new SqlParameter[1];
3190 Param[0] = new SqlParameter("@ContactId", ContactId);
3191
3192 DataTable dt = SqlHelper.ExecuteDatatable(CommandType.StoredProcedure, "GetLastNoteWithDetails", Param);
3193
3194 var d = (from DataRow row in dt.Rows
3195 select new LastNoteWithDetails
3196 {
3197 ContactId = Convert.ToInt32(((row["ContactId"] == DBNull.Value || row["ContactId"] == null) ? "0" : row["ContactId"]).ToString()),
3198 BrokerId = Convert.ToInt32(((row["BrokerId"] == DBNull.Value || row["BrokerId"] == null) ? "0" : row["BrokerId"]).ToString()),
3199 FName = ((row["FName"] == DBNull.Value || row["FName"] == null) ? " " : row["FName"]).ToString(),
3200 LName = ((row["LName"] == DBNull.Value || row["LName"] == null) ? " " : row["LName"]).ToString(),
3201 MobileNumber = ((row["MobileNumber"] == DBNull.Value || row["MobileNumber"] == null) ? " " : row["MobileNumber"]).ToString(),
3202 LastNote = ((row["LastNote"] == DBNull.Value || row["LastNote"] == null) ? " " : row["LastNote"]).ToString(),
3203 BrokerEmail = ((row["BrokerEmail"] == DBNull.Value || row["BrokerEmail"] == null) ? " " : row["BrokerEmail"]).ToString(),
3204 BrokerName = ((row["BrokerName"] == DBNull.Value || row["BrokerName"] == null) ? " " : row["BrokerName"]).ToString(),
3205 PrimaryContact = ((row["PrimaryContact"] == DBNull.Value || row["PrimaryContact"] == null) ? " " : row["PrimaryContact"]).ToString(),
3206 SecondaryContact = ((row["SecondaryContact"] == DBNull.Value || row["SecondaryContact"] == null) ? " " : row["SecondaryContact"]).ToString(),
3207
3208
3209 }).ToList();
3210
3211 if (d != null && d.Count() > 0)
3212 {
3213 _detail = d[0];
3214 // add signature to message
3215 // Message += Environment.NewLine + _userName + Environment.NewLine + "Please reply to " + _usertel;
3216 if (!string.IsNullOrWhiteSpace(_detail.SecondaryContact))
3217 _usertel = _detail.SecondaryContact;
3218 else if (!string.IsNullOrWhiteSpace(_detail.PrimaryContact))
3219 _usertel = _detail.PrimaryContact;
3220 else
3221 _usertel = "";
3222
3223 if (!string.IsNullOrEmpty(_detail.BrokerName))
3224 Message += Environment.NewLine + _detail.BrokerName + Environment.NewLine + "Please reply to " + _usertel;
3225
3226 if (!string.IsNullOrWhiteSpace(Message) && Message.Length > _maxlenth)
3227 {
3228 Message = Message.Substring(0, _maxlenth);
3229 }
3230
3231 string ClickaTellUser = Convert.ToString(ConfigurationManager.AppSettings["ClickaTellUser"] ?? "");
3232 string ClickaTellPassword = Convert.ToString(ConfigurationManager.AppSettings["ClickaTellPassword"] ?? "");
3233 string ClickaTellAPIId = Convert.ToString(ConfigurationManager.AppSettings["ClickaTellAPIId"] ?? "");
3234 string ClickaTellURL = Convert.ToString(ConfigurationManager.AppSettings["ClickaTellURL"] ?? "");
3235
3236 // var _status = ClickaTellURL + "?user=" + ClickaTellUser + "&password=" + ClickaTellPassword + "&api_id=" + ClickaTellAPIId + "&to=" + MobileNumbers + "&text=" + Message;
3237
3238 System.Net.WebClient client = new System.Net.WebClient();
3239 // Add a user agent header in case the requested URI contains a query.
3240 client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)");
3241 client.QueryString.Add("user", ClickaTellUser);
3242 client.QueryString.Add("password", ClickaTellPassword);
3243 client.QueryString.Add("api_id", ClickaTellAPIId);
3244 client.QueryString.Add("to", MobileNumbers);
3245 client.QueryString.Add("text", HttpUtility.UrlEncode(Message));
3246
3247 // concatenate if message length is more than 140 characters (depends on unicode chars in message-text )
3248 client.QueryString.Add("concat", "2");
3249 // add sender id
3250 client.QueryString.Add("from", "Cap Finance");
3251
3252 string baseurl = ClickaTellURL;
3253 Stream data = client.OpenRead(baseurl);
3254 StreamReader reader = new StreamReader(data);
3255 string s = reader.ReadToEnd();
3256 data.Close();
3257 reader.Close();
3258 if (s.Contains("ERR"))
3259 {
3260 _chk = 0;
3261 }
3262 else
3263 {
3264 _chk = 1;
3265 }
3266 }
3267
3268 }
3269 catch(Exception ex)
3270 {
3271 Helper.ErrorLog(ex.InnerException, "HomeController", "SendTextMsg", ex.Message);
3272 }
3273 }
3274 else
3275 {
3276 _chk = -2;
3277 }
3278 return Json(_chk, JsonRequestBehavior.AllowGet);
3279 }
3280
3281 #region Client Fact Find For Client --------
3282
3283 #region Mortgage FactFind
3284
3285 //Mortgage_Fact_Find
3286
3287 [App_Start.SessionTimeOutActionFilter]
3288 public ActionResult mortgage_fact_find(string Id)
3289 {
3290 MortgageFact obj = new MortgageFact();
3291 try
3292 {
3293 //new Occfinance.Models.ApplicationForm()
3294 if (!string.IsNullOrEmpty(Id))
3295 {
3296 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
3297 DataSet clientReg = Qmortgage.GetClientRegistrationID(Convert.ToInt32(Id));
3298
3299
3300 // client registration
3301 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
3302
3303 // employment and incom
3304 tblEmploymentAndIncome[] employmentAndIncome = DataTableHelper.CreateListFromTable<tblEmploymentAndIncome>(clientReg.Tables[2]).ToArray<tblEmploymentAndIncome>();
3305
3306 // deductions
3307 tblPayslipDeduction[] paySlip = DataTableHelper.CreateListFromTable<tblPayslipDeduction>(clientReg.Tables[3]).ToArray<tblPayslipDeduction>();
3308
3309 // self employment
3310 tblSelfEmployed[] selfEmployed = DataTableHelper.CreateListFromTable<tblSelfEmployed>(clientReg.Tables[4]).ToArray<tblSelfEmployed>();
3311
3312 // Other incom info
3313 tblOtherIncomeInformation[] otherIncomeInfo = DataTableHelper.CreateListFromTable<tblOtherIncomeInformation>(clientReg.Tables[5]).ToArray<tblOtherIncomeInformation>();
3314
3315 // source of fund
3316 tblSourceofFundsforPurchase otherSourceofFund = DataTableHelper.CreateListFromTable<tblSourceofFundsforPurchase>(clientReg.Tables[6]).ToArray<tblSourceofFundsforPurchase>().FirstOrDefault();
3317
3318 //current commitments
3319 tblCurrentCommitments[] currentCommitments = DataTableHelper.CreateListFromTable<tblCurrentCommitments>(clientReg.Tables[15]).ToArray<tblCurrentCommitments>().ToArray();
3320
3321 // New_Mortgage_Property
3322 tblNew_Mortgage_Property_Details[] newMortgageProp = DataTableHelper.CreateListFromTable<tblNew_Mortgage_Property_Details>(clientReg.Tables[7]).ToArray<tblNew_Mortgage_Property_Details>();
3323
3324 tblOther_Mortgages otherMortGage = DataTableHelper.CreateListFromTable<tblOther_Mortgages>(clientReg.Tables[8]).ToArray<tblOther_Mortgages>().FirstOrDefault();
3325
3326 //Other_Mortgages
3327 tblResidentialMortgage[] residentialMortgage = DataTableHelper.CreateListFromTable<tblResidentialMortgage>(clientReg.Tables[9]).ToArray<tblResidentialMortgage>();
3328
3329 //Expenditure
3330 tblExpenditure[] expenditure = DataTableHelper.CreateListFromTable<tblExpenditure>(clientReg.Tables[10]).ToArray<tblExpenditure>();
3331
3332 //Mortgage_Requirement_Factors
3333 tblMortgage_Requirement_Factors mortgageRequirement = DataTableHelper.CreateListFromTable<tblMortgage_Requirement_Factors>(clientReg.Tables[11]).ToArray<tblMortgage_Requirement_Factors>().FirstOrDefault();
3334
3335 //Additional_Property_Info
3336 tblAdditional_Property_Info additionalProperty = DataTableHelper.CreateListFromTable<tblAdditional_Property_Info>(clientReg.Tables[12]).ToArray<tblAdditional_Property_Info>().FirstOrDefault();
3337
3338 //Current_Savings_Arrangements
3339 tblCurrent_Savings_Arrangements[] currentSavings = DataTableHelper.CreateListFromTable<tblCurrent_Savings_Arrangements>(clientReg.Tables[14]).ToArray<tblCurrent_Savings_Arrangements>();
3340
3341 //Current_Protection_Arrangements
3342 tblCurrent_Protection_Arrangements CurrentProtection = DataTableHelper.CreateListFromTable<tblCurrent_Protection_Arrangements>(clientReg.Tables[16]).ToArray<tblCurrent_Protection_Arrangements>().FirstOrDefault();
3343
3344 //Employment_Benefit
3345 tblEmployment_Benefit[] employmentBenefit = DataTableHelper.CreateListFromTable<tblEmployment_Benefit>(clientReg.Tables[17]).ToArray<tblEmployment_Benefit>();
3346
3347 //Current_Pension_Investment_Arrangements
3348 tblCurrent_Pension_Investment_Arrangements currentPensionInvestment = DataTableHelper.CreateListFromTable<tblCurrent_Pension_Investment_Arrangements>(clientReg.Tables[18]).ToArray<tblCurrent_Pension_Investment_Arrangements>().FirstOrDefault();
3349
3350 //Current_Buildings_Contents_Arrangements
3351 tblCurrent_Buildings_Contents_Arrangements currentBuildingsContents = DataTableHelper.CreateListFromTable<tblCurrent_Buildings_Contents_Arrangements>(clientReg.Tables[19]).ToArray<tblCurrent_Buildings_Contents_Arrangements>().FirstOrDefault();
3352
3353 //Dependant
3354 tblDependant[] dependant = DataTableHelper.CreateListFromTable<tblDependant>(clientReg.Tables[21]).ToArray<tblDependant>();
3355
3356 // employment
3357 tblEmployment[] employment = DataTableHelper.CreateListFromTable<tblEmployment>(clientReg.Tables[1]).ToArray<tblEmployment>();
3358
3359
3360
3361 // set data in object
3362 obj.ClientRegistration = clientRegistration;
3363 obj.EmploymentAndIncome = new tblEmploymentAndIncome();
3364 obj.Deduction = paySlip;
3365 obj.SelfEmployed = new tblSelfEmployed();
3366 obj.OtherIncomeInformation = otherIncomeInfo;
3367 obj.SourceOfFund = otherSourceofFund;
3368 obj.CurrentCommitments = new tblCurrentCommitments();
3369 obj.MortgageProperty = newMortgageProp;
3370 obj.OtherMortgage = otherMortGage;
3371 obj.ResidentialMortgage = residentialMortgage;
3372 obj.Expenditure = expenditure;
3373 obj.MortgageRequirement = mortgageRequirement;
3374 obj.AdditionalProperty = additionalProperty;
3375 obj.CurrentSavings = currentSavings;
3376 obj.CurrentProtection = CurrentProtection;
3377 obj.EmploymentBenefit = employmentBenefit;
3378 obj.CurrentPensionInvestment = currentPensionInvestment;
3379 obj.CurrentBuildingsContents = currentBuildingsContents;
3380 obj.Dependant = dependant;
3381 obj.Employment_Details = employment;
3382
3383
3384
3385 List<Applicant> objApplicant = new List<Applicant>();
3386 objApplicant.Add(new Applicant() { ApplicantIDEmployment = employmentAndIncome.Where(a => a.ReferId == null).Select(s => s.EmploymentIncomeId).FirstOrDefault(), ApplicantId = selfEmployed.Where(a => a.ReferId == null).Select(s => s.SelfEmployedId).FirstOrDefault(), ApplicantName = clientRegistration[0].Forename });
3387 objApplicant.Add(new Applicant() { ApplicantIDEmployment = employmentAndIncome.Where(a => a.ReferId != null).Select(s => s.EmploymentIncomeId).FirstOrDefault(), ApplicantId = selfEmployed.Where(a => a.ReferId != null).Select(s => s.SelfEmployedId).FirstOrDefault(), ApplicantName = clientRegistration[1].Forename });
3388
3389
3390
3391
3392 obj.Employment = new Employment
3393 {
3394 EmploymentIncome = employmentAndIncome,
3395 SelfEmployed = selfEmployed,
3396 OtherIncomeInfo = otherIncomeInfo,
3397 Count = clientRegistration[0].HasReference ? 1 : 0,
3398 ApplicantInfo = objApplicant
3399
3400 };
3401
3402
3403 ViewBag.Applicants = objApplicant;
3404 }
3405
3406
3407 List<Countries> countrylist = new List<Countries>();
3408
3409 // Get countries from cutureinfo
3410 foreach (var item in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
3411 {
3412 var ri = new RegionInfo(item.Name);
3413 if (countrylist.Where(m => m.Name == ri.DisplayName).Count() == 0)
3414 countrylist.Add(new Countries { Name = ri.DisplayName, ID = item.Name });
3415 }
3416
3417
3418 countrylist = countrylist.OrderBy(m => m.Name).ToList();
3419 countrylist.Add(new Countries { ID = "0", Name = "Others" });
3420 countrylist.Insert(0, new Countries { ID = "cy-GB", Name = "United Kingdom" });
3421
3422 ViewBag.Countries = new SelectList(countrylist, "ID", "Name");
3423
3424 return View(obj);
3425 }
3426 catch(Exception ex)
3427 {
3428 Helper.ErrorLog(ex.InnerException, "HomeController", "mortgage_fact_find", ex.Message);
3429 return null;
3430 }
3431
3432 }
3433 /// <summary>
3434 /// Ajax post for morgage fact find
3435 /// </summary>
3436 /// <param name="model"></param>
3437 /// <returns></returns>
3438
3439 [HttpPost]
3440 [App_Start.SessionTimeOutActionFilter]
3441 public ActionResult mortgage_fact_find(MortgageFact model, tblCurrentCommitments commitmentmodel, tblEmploymentAndIncome employmentIncomemodel, tblSelfEmployed selfemployedModel, tblOtherIncomeInformation otherIncomeInformation, tblCurrent_Pension_Investment_Arrangements currentPensionInvestment, tblCurrent_Protection_Arrangements currentProtection, tblResidentialMortgage residentialMortgage, tblOther_Mortgages investmentportfolio, tblAdditional_Property_Info newmortgageandpropertydetails, string Index = "", string ClientRegistrationID = "0", int employmentType = 0, int applicantid = 0, int Owner = 0)
3442 {
3443
3444 int PrimaryClientId = int.Parse(ClientRegistrationID);
3445
3446 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
3447 DataSet clientReg = Qmortgage.GetClientRegistrationID(PrimaryClientId);
3448
3449 switch (Index)
3450 {
3451 #region save client registration 0
3452 case "0":
3453 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3454 {
3455 con.Open();
3456 SqlTransaction trans = con.BeginTransaction();
3457 try
3458 {
3459 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
3460
3461 model.ClientRegistration[0].ClientRegistrationID = clientRegistration[0].ClientRegistrationID;
3462 model.ClientRegistration[0].ClientName = clientRegistration[0].ClientName;
3463 model.ClientRegistration[0].BrokerId = clientRegistration[0].BrokerId;
3464 model.ClientRegistration[0].slamet = clientRegistration[0].slamet;
3465 Qmortgage.AddClientRegistration(model.ClientRegistration[0], true, trans, con);
3466
3467 if (model.ClientRegistration[0].HasReference)
3468 {
3469 model.ClientRegistration[1].ClientRegistrationID = clientRegistration[1].ClientRegistrationID;
3470 model.ClientRegistration[1].ClientName = clientRegistration[1].ClientName;
3471 model.ClientRegistration[1].BrokerId = clientRegistration[1].BrokerId;
3472 model.ClientRegistration[1].slamet = clientRegistration[1].slamet;
3473 model.ClientRegistration[1].ReferId = PrimaryClientId;
3474 Qmortgage.AddClientRegistration(model.ClientRegistration[1], true, trans, con);
3475 }
3476
3477 // Dependent
3478 tblDependant[] dependantData = DataTableHelper.CreateListFromTable<tblDependant>(clientReg.Tables[21]).ToArray<tblDependant>();
3479
3480 model.Dependant[0].DependantID = dependantData[0].DependantID;
3481 model.Dependant[0].ClientRegistrationID = PrimaryClientId;
3482 Qmortgage.AddUpdateDependant(model.Dependant[0], true, trans, con);
3483
3484 if (model.ClientRegistration[0].HasReference)
3485 {
3486 model.Dependant[1].DependantID = dependantData[1].DependantID;
3487 model.Dependant[1].ClientRegistrationID = PrimaryClientId;
3488 model.Dependant[1].ReferId = PrimaryClientId;
3489 Qmortgage.AddUpdateDependant(model.Dependant[1], true, trans, con);
3490 }
3491
3492 trans.Commit();
3493 }
3494 catch(Exception ex)
3495 {
3496 Helper.ErrorLog(ex.InnerException, "HomeController", "mortgage_fact_find", ex.Message);
3497 trans.Rollback();
3498 }
3499 }
3500
3501 break;
3502 #endregion
3503
3504 #region employment and income 1
3505 case "1":
3506 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3507 {
3508 con.Open();
3509 SqlTransaction trans = con.BeginTransaction();
3510
3511 // self employment
3512 tblSelfEmployed[] selfEmployed = DataTableHelper.CreateListFromTable<tblSelfEmployed>(clientReg.Tables[4]).ToArray<tblSelfEmployed>();
3513
3514 // employment and incom
3515 tblEmploymentAndIncome[] employmentAndIncome = DataTableHelper.CreateListFromTable<tblEmploymentAndIncome>(clientReg.Tables[2]).ToArray<tblEmploymentAndIncome>();
3516
3517
3518 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
3519
3520 var clientRegis_ReferID = clientRegistration.Where(t => t.ClientRegistrationID == applicantid).Select(t => t.ReferId).FirstOrDefault();
3521
3522
3523 try
3524 {
3525 //employment and income
3526 if (employmentType == 1)
3527 {
3528
3529 if (employmentAndIncome.Where(a => (a.EmploymentIncomeId == applicantid && a.ReferId == PrimaryClientId)).Count() > 0)
3530 {
3531 employmentIncomemodel.EmploymentIncomeId = applicantid;
3532 employmentIncomemodel.ReferId = PrimaryClientId;
3533 Qmortgage.AddEmploymentAndIncome(employmentIncomemodel, true, trans, con);
3534 }
3535 else if (employmentAndIncome.Where(a => (a.EmploymentIncomeId == applicantid && a.ReferId == null)).Count() > 0)
3536 {
3537 employmentIncomemodel.EmploymentIncomeId = applicantid;
3538 employmentIncomemodel.ReferId = null;
3539 Qmortgage.AddEmploymentAndIncome(employmentIncomemodel, true, trans, con);
3540 }
3541
3542
3543 }
3544
3545
3546 // self employment code
3547 else if (employmentType > 1)
3548 {
3549 List<tblOtherIncomeInformation> objotherIncomeInformation = DataTableHelper.CreateListFromTable<tblOtherIncomeInformation>(clientReg.Tables[5]).ToList<tblOtherIncomeInformation>();
3550
3551
3552 // unemployment
3553 if (employmentType == 2)
3554 {
3555
3556 if (selfEmployed.Where(a => (a.SelfEmployedId == applicantid && a.ReferId == PrimaryClientId)).Count() > 0)
3557 {
3558 selfemployedModel.SelfEmployedId = applicantid;
3559 selfemployedModel.ReferId = PrimaryClientId;
3560 Qmortgage.AddSelfEmployed_UnEmployment(selfemployedModel, true, trans, con);
3561 }
3562 else if (selfEmployed.Where(a => (a.SelfEmployedId == applicantid && a.ReferId == null)).Count() > 0)
3563 {
3564 selfemployedModel.SelfEmployedId = applicantid;
3565 selfemployedModel.ReferId = null;
3566 Qmortgage.AddSelfEmployed_UnEmployment(selfemployedModel, true, trans, con);
3567 }
3568
3569 }
3570 // self employment
3571 else
3572 {
3573
3574 if (selfEmployed.Where(a => (a.SelfEmployedId == applicantid && a.ReferId == PrimaryClientId)).Count() > 0)
3575 {
3576 selfemployedModel.SelfEmployedId = applicantid;
3577 selfemployedModel.ReferId = PrimaryClientId;
3578 Qmortgage.AddSelfEmployed(selfemployedModel, true, trans, con);
3579 }
3580 else if (selfEmployed.Where(a => (a.SelfEmployedId == applicantid && a.ReferId == null)).Count() > 0)
3581 {
3582 selfemployedModel.SelfEmployedId = applicantid;
3583 selfemployedModel.ReferId = null;
3584 Qmortgage.AddSelfEmployed(selfemployedModel, true, trans, con);
3585 }
3586
3587 }
3588
3589 //int selectimpid = Qmortgage.AddSelfEmployed(selfemployedModel, true, trans, con);
3590
3591 //
3592 var objOtherIncomeInformation = objotherIncomeInformation.Where(m => m.SelfEmployedId == applicantid).FirstOrDefault();
3593
3594 if (objOtherIncomeInformation != null)
3595 {
3596
3597 otherIncomeInformation.OtherIncomeInformationId = objOtherIncomeInformation.OtherIncomeInformationId;
3598 otherIncomeInformation.SelfEmployedId = applicantid;
3599 otherIncomeInformation.ReferId = objOtherIncomeInformation.ReferId;
3600 otherIncomeInformation.ClientRegistrationID = PrimaryClientId;
3601
3602
3603
3604 Qmortgage.AddOtherIncomeInformation(otherIncomeInformation, true, trans, con);
3605 }
3606
3607
3608
3609 //
3610 }
3611
3612
3613 trans.Commit();
3614 }
3615 catch(Exception ex)
3616 {
3617 Helper.ErrorLog(ex.InnerException, "HomeController", "mortgage_fact_find", ex.Message);
3618 trans.Rollback();
3619 }
3620 }
3621 break;
3622 #endregion
3623
3624 #region Payslip deduction 2
3625 case "2":
3626 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3627 {
3628 con.Open();
3629 SqlTransaction trans = con.BeginTransaction();
3630 try
3631 {
3632 tblPayslipDeduction[] deduction = DataTableHelper.CreateListFromTable<tblPayslipDeduction>(clientReg.Tables[3]).ToArray<tblPayslipDeduction>();
3633 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
3634
3635 model.Deduction[0].PayslipDeductionId = deduction[0].PayslipDeductionId;
3636 model.Deduction[0].ClientRegistrationID = PrimaryClientId;
3637 Qmortgage.AddPayslipDeduction(model.Deduction[0], true, trans, con);
3638
3639 if (clientRegistration[0].HasReference)
3640 {
3641 model.Deduction[1].PayslipDeductionId = deduction[1].PayslipDeductionId;
3642 model.Deduction[1].ClientRegistrationID = PrimaryClientId;
3643 model.Deduction[1].ReferId = PrimaryClientId;
3644 Qmortgage.AddPayslipDeduction(model.Deduction[1], true, trans, con);
3645 }
3646 trans.Commit();
3647 }
3648 catch(Exception ex)
3649 {
3650 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3651 trans.Rollback();
3652 }
3653 }
3654 break;
3655 #endregion
3656
3657 #region Expenditure 3
3658 case "3":
3659 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3660 {
3661 con.Open();
3662 SqlTransaction trans = con.BeginTransaction();
3663 try
3664 {
3665
3666 tblExpenditure[] expenditure = DataTableHelper.CreateListFromTable<tblExpenditure>(clientReg.Tables[10]).ToArray<tblExpenditure>();
3667 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
3668
3669 //if (Index == "4")
3670 //{
3671 model.Expenditure[0].Total_Income_All_Sources = expenditure[0].Total_Income_All_Sources;
3672 model.Expenditure[0].Total_Net_Monthly_Income_A = expenditure[0].Total_Net_Monthly_Income_A;
3673 if (clientRegistration[0].HasReference)
3674 {
3675 model.Expenditure[1].Total_Income_All_Sources = expenditure[1].Total_Income_All_Sources;
3676 model.Expenditure[1].Total_Net_Monthly_Income_A = expenditure[1].Total_Net_Monthly_Income_A;
3677 }
3678
3679 //}
3680
3681 model.Expenditure[0].ExpenditureID = expenditure[0].ExpenditureID;
3682 model.Expenditure[0].ClientRegistrationID = PrimaryClientId;
3683 Qmortgage.AddExpenditure(model.Expenditure[0], true, trans, con);
3684
3685 if (clientRegistration[0].HasReference)
3686 {
3687 model.Expenditure[1].ExpenditureID = expenditure[1].ExpenditureID;
3688 model.Expenditure[1].ClientRegistrationID = PrimaryClientId;
3689 model.Expenditure[1].ReferId = PrimaryClientId;
3690 Qmortgage.AddExpenditure(model.Expenditure[1], true, trans, con);
3691 }
3692 trans.Commit();
3693 }
3694 catch (Exception ex)
3695 {
3696 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3697 trans.Rollback();
3698 }
3699 }
3700 break;
3701
3702 #endregion
3703
3704 #region SourceOfFund 4
3705 case "4":
3706 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3707 {
3708 con.Open();
3709 SqlTransaction trans = con.BeginTransaction();
3710 try
3711 {
3712 tblSourceofFundsforPurchase[] sourceOfFund = DataTableHelper.CreateListFromTable<tblSourceofFundsforPurchase>(clientReg.Tables[6]).ToArray<tblSourceofFundsforPurchase>();
3713
3714 model.SourceOfFund.SourceofFundsforPurchaseId = sourceOfFund[0].SourceofFundsforPurchaseId;
3715 model.SourceOfFund.ClientRegistrationID = PrimaryClientId;
3716 Qmortgage.AddSourceofFundsforPurchase(model.SourceOfFund, true, trans, con);
3717
3718 trans.Commit();
3719 }
3720 catch (Exception ex)
3721 {
3722 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3723 trans.Rollback();
3724 }
3725 }
3726 break;
3727
3728 #endregion
3729
3730 #region Current Commitments 5
3731 case "5":
3732 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3733 {
3734 con.Open();
3735 SqlTransaction trans = con.BeginTransaction();
3736 try
3737 {
3738 #region Commented
3739 //DataSet dscommitments = Qmortgage.GetClientRegistrationID(Convert.ToInt32(ClientRegistrationID));
3740 //List<tblCurrentCommitments> commitments = Occfinance.Code.DataTableHelper.CreateListFromTable<tblCurrentCommitments>(dscommitments.Tables[0]).ToArray<tblCurrentCommitments>().ToList();
3741
3742 //int incr=0;
3743 //foreach (var data in model.CurrentCommitments)
3744 //{
3745 // int ID=0;
3746 // foreach (var item in commitments.Where(m => m.CurrentCommitmentsId != 0).ToList())
3747 // {
3748 // // check if record exist
3749 // if (data.CurrentCommitmentsId==item.CurrentCommitmentsId)
3750 // {
3751 // ID = item.CurrentCommitmentsId;
3752 // }
3753 // }
3754
3755 // model.CurrentCommitments[incr].CurrentCommitmentsId = ID;
3756 // model.CurrentCommitments[incr].ClientRegistrationID = PrimaryClientId;
3757 // Qmortgage.AddCurrentCommitments(model.CurrentCommitments[incr], true, trans, con);
3758
3759
3760 //incr++;
3761 //}
3762 #endregion
3763
3764 commitmentmodel.ClientRegistrationID = PrimaryClientId;
3765 commitmentmodel.ReferId = PrimaryClientId;
3766 commitmentmodel.Owner = Owner;
3767 Qmortgage.AddCurrentCommitments(commitmentmodel, true, trans, con);
3768
3769 trans.Commit();
3770 }
3771 catch (Exception ex)
3772 {
3773 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3774 trans.Rollback();
3775 }
3776 }
3777 break;
3778
3779 #endregion
3780
3781 #region Residential Mortgage 6
3782 case "6":
3783 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3784 {
3785 con.Open();
3786 SqlTransaction trans = con.BeginTransaction();
3787 try
3788 {
3789 residentialMortgage.ClientRegistrationID = PrimaryClientId;
3790 residentialMortgage.ReferId = PrimaryClientId;
3791 Qmortgage.AddResidentialMortgage(residentialMortgage, true, trans, con);
3792
3793 trans.Commit();
3794 }
3795 catch (Exception ex)
3796 {
3797 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3798 trans.Rollback();
3799 }
3800 }
3801 break;
3802
3803 #endregion
3804
3805 #region New Mortgage & Property Details 7
3806
3807 case "7":
3808 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3809 {
3810
3811
3812 con.Open();
3813 SqlTransaction trans = con.BeginTransaction();
3814 try
3815 {
3816 newmortgageandpropertydetails.ClientRegistrationID = PrimaryClientId;
3817 newmortgageandpropertydetails.ReferId = PrimaryClientId;
3818
3819 Qmortgage.AddUpdateNewMortgageandPropertyDetail(newmortgageandpropertydetails, true, trans, con);
3820
3821
3822 trans.Commit();
3823 }
3824 catch (Exception ex)
3825 {
3826 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3827 trans.Rollback();
3828 }
3829 }
3830 break;
3831
3832
3833 #endregion
3834
3835 #region Investment Portfolio 8
3836 case "8":
3837 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3838 {
3839
3840
3841
3842 con.Open();
3843 SqlTransaction trans = con.BeginTransaction();
3844 try
3845 {
3846
3847 investmentportfolio.ClientRegistrationID = PrimaryClientId;
3848 investmentportfolio.ReferId = PrimaryClientId;
3849 Qmortgage.AddUpdateInvestmentPortfolio(investmentportfolio, true, trans, con);
3850
3851 trans.Commit();
3852 }
3853 catch (Exception ex)
3854 {
3855 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3856 trans.Rollback();
3857 }
3858 }
3859 break;
3860
3861
3862 #endregion
3863
3864 #region Mortgage Requirement 9
3865
3866 case "9":
3867 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3868 {
3869 con.Open();
3870 SqlTransaction trans = con.BeginTransaction();
3871 try
3872 {
3873 tblMortgage_Requirement_Factors mortgageRequirement = DataTableHelper.CreateListFromTable<tblMortgage_Requirement_Factors>(clientReg.Tables[11]).ToArray<tblMortgage_Requirement_Factors>().FirstOrDefault();
3874
3875 model.MortgageRequirement.Mortgage_Requirement_FactorsID = mortgageRequirement.Mortgage_Requirement_FactorsID;
3876 model.MortgageRequirement.ClientRegistrationID = PrimaryClientId;
3877 Qmortgage.AddUpdateMortgageRequirementFactors(model.MortgageRequirement, true, trans, con);
3878 trans.Commit();
3879 }
3880 catch (Exception ex)
3881 {
3882 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3883 trans.Rollback();
3884 }
3885 }
3886 break;
3887
3888 #endregion
3889
3890 #region Additional Property 10
3891
3892 case "10":
3893 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3894 {
3895 con.Open();
3896 SqlTransaction trans = con.BeginTransaction();
3897 try
3898 {
3899 tblAdditional_Property_Info additionalProperty = DataTableHelper.CreateListFromTable<tblAdditional_Property_Info>(clientReg.Tables[12]).ToArray<tblAdditional_Property_Info>().FirstOrDefault();
3900
3901 model.AdditionalProperty.tblAdditional_Property_InfoID = additionalProperty.tblAdditional_Property_InfoID;
3902 model.AdditionalProperty.ClientRegistrationID = PrimaryClientId;
3903 Qmortgage.AddUpdateAdditionalProperty(model.AdditionalProperty, true, trans, con);
3904
3905 trans.Commit();
3906 }
3907 catch (Exception ex)
3908 {
3909 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3910 trans.Rollback();
3911 }
3912 }
3913 break;
3914
3915 #endregion
3916
3917 #region Current Savings Arrangements 11
3918
3919 case "11":
3920 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3921 {
3922 con.Open();
3923 SqlTransaction trans = con.BeginTransaction();
3924 try
3925 {
3926 tblCurrent_Savings_Arrangements[] currentSavings = DataTableHelper.CreateListFromTable<tblCurrent_Savings_Arrangements>(clientReg.Tables[14]).ToArray<tblCurrent_Savings_Arrangements>();
3927 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
3928
3929 model.CurrentSavings[0].Current_Savings_ArrangementsID = currentSavings[0].Current_Savings_ArrangementsID;
3930 model.CurrentSavings[0].ClientRegistrationID = PrimaryClientId;
3931 Qmortgage.AddUpdateCurrentSavingArrangements(model.CurrentSavings[0], true, trans, con);
3932
3933 if (clientRegistration[0].HasReference)
3934 {
3935 model.CurrentSavings[1].Current_Savings_ArrangementsID = currentSavings[1].Current_Savings_ArrangementsID;
3936 model.CurrentSavings[1].ClientRegistrationID = PrimaryClientId;
3937 model.CurrentSavings[1].ReferId = PrimaryClientId;
3938 Qmortgage.AddUpdateCurrentSavingArrangements(model.CurrentSavings[1], true, trans, con);
3939 }
3940
3941 trans.Commit();
3942 }
3943 catch (Exception ex)
3944 {
3945 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3946 trans.Rollback();
3947 }
3948 }
3949 break;
3950 #endregion
3951
3952 #region Current Protection Arrangements(including Life/CIC/Income protection) 12
3953
3954 case "12":
3955 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3956 {
3957 con.Open();
3958 SqlTransaction trans = con.BeginTransaction();
3959 try
3960 {
3961 currentProtection.ClientRegistrationID = PrimaryClientId;
3962 currentProtection.ReferId = PrimaryClientId;
3963 Qmortgage.AddUpdateProtection(currentProtection, true, trans, con);
3964
3965
3966 trans.Commit();
3967 }
3968 catch (Exception ex)
3969 {
3970 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
3971 trans.Rollback();
3972 }
3973 }
3974 break;
3975
3976 #endregion
3977
3978 #region Employment Benefit 13
3979
3980 case "13":
3981
3982 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
3983 {
3984 con.Open();
3985 SqlTransaction trans = con.BeginTransaction();
3986 try
3987 {
3988 tblEmployment_Benefit[] employmentBenefit = DataTableHelper.CreateListFromTable<tblEmployment_Benefit>(clientReg.Tables[17]).ToArray<tblEmployment_Benefit>();
3989 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
3990 model.EmploymentBenefit[0].Employment_BenefitID = employmentBenefit[0].Employment_BenefitID;
3991 model.EmploymentBenefit[0].ClientRegistrationID = PrimaryClientId;
3992 Qmortgage.AddUpdateEmploymentBenefit(model.EmploymentBenefit[0], true, trans, con);
3993
3994 if (clientRegistration[0].HasReference)
3995 {
3996 model.EmploymentBenefit[1].Employment_BenefitID = employmentBenefit[1].Employment_BenefitID;
3997 model.EmploymentBenefit[1].ClientRegistrationID = PrimaryClientId;
3998 model.EmploymentBenefit[1].ReferId = PrimaryClientId;
3999 Qmortgage.AddUpdateEmploymentBenefit(model.EmploymentBenefit[1], true, trans, con);
4000 }
4001
4002 trans.Commit();
4003 }
4004 catch (Exception ex)
4005 {
4006 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
4007 trans.Rollback();
4008 }
4009 }
4010 break;
4011 #endregion
4012
4013 #region Current Pension 14
4014
4015 case "14":
4016 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
4017 {
4018 con.Open();
4019 SqlTransaction trans = con.BeginTransaction();
4020 try
4021 {
4022 currentPensionInvestment.ClientRegistrationID = PrimaryClientId;
4023 currentPensionInvestment.ReferId = PrimaryClientId;
4024 Qmortgage.AddUpdatePensionInvestment(currentPensionInvestment, true, trans, con);
4025
4026 trans.Commit();
4027 }
4028 catch (Exception ex)
4029 {
4030 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
4031 trans.Rollback();
4032 }
4033 }
4034 break;
4035
4036 #endregion
4037
4038 #region Current Buildings / Contents Arrangements 15
4039
4040 case "15":
4041 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
4042 {
4043 con.Open();
4044 SqlTransaction trans = con.BeginTransaction();
4045 try
4046 {
4047 tblCurrent_Buildings_Contents_Arrangements currentBuildingsContents = DataTableHelper.CreateListFromTable<tblCurrent_Buildings_Contents_Arrangements>(clientReg.Tables[19]).ToArray<tblCurrent_Buildings_Contents_Arrangements>().FirstOrDefault();
4048
4049 model.CurrentBuildingsContents.Current_Buildings_Contents_ArrangementsID = currentBuildingsContents.Current_Buildings_Contents_ArrangementsID;
4050 model.CurrentBuildingsContents.ClientRegistrationID = PrimaryClientId;
4051 Qmortgage.AddUpdateCurrentBuildingContent(model.CurrentBuildingsContents, true, trans, con);
4052
4053 trans.Commit();
4054 }
4055 catch (Exception ex)
4056 {
4057 Helper.ErrorLog(ex.InnerException, "HomeController", "Mortgage_fact_find", ex.Message);
4058 trans.Rollback();
4059 }
4060 }
4061 break;
4062
4063 #endregion
4064
4065 #region Default
4066 default:
4067
4068 break;
4069
4070 #endregion
4071
4072 }
4073
4074
4075 return Json("", JsonRequestBehavior.AllowGet);
4076 }
4077
4078 // new code from addreess info
4079
4080 #region | Address CRUD |
4081
4082 public JsonResult SaveAddressInfo(AddressInfo model)
4083 {
4084 string result = "";
4085 // save address data
4086 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4087 using (SqlConnection con = new SqlConnection(SqlHelper.ConnectionString()))
4088 {
4089 con.Open();
4090 SqlTransaction trans = con.BeginTransaction();
4091 try
4092 {
4093 Qmortgage.AddAddressClientRegistration(model, true, trans, con);
4094 trans.Commit();
4095 result = "Address saved successfully";
4096 }
4097 catch (Exception ex)
4098 {
4099 Helper.ErrorLog(ex.InnerException, "HomeController", "SaveAddressInfo", ex.Message);
4100 trans.Rollback();
4101 result = "Error while saving address";
4102 }
4103 }
4104 return Json(result, JsonRequestBehavior.AllowGet);
4105 }
4106
4107 public PartialViewResult GetAddress(int ApplicantID, int AddressID = 0)
4108 {
4109 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4110 DataSet address = Qmortgage.GetAddressList(ApplicantID);
4111 List<AddressInfo> addresslist = DataTableHelper.CreateListFromTableForAll<AddressInfo>(address.Tables[0]).ToList<AddressInfo>();
4112 //var model = new List<AddressInfo> {
4113
4114 // new AddressInfo { FactFindAddressID=1, NameOfEmployer = "Employer 1",ResidentialStatus="Private Tenant"} ,
4115 // new AddressInfo { FactFindAddressID=2, NameOfEmployer = "Employer 2",ResidentialStatus="Living with Friends"}
4116 //};
4117 return PartialView("_PartialEditAddress", addresslist.Where(a => a.FactFindAddressID == AddressID).FirstOrDefault() ?? new AddressInfo { ApplicantID = ApplicantID });
4118 }
4119
4120 public ActionResult GetAddressList(string AddressDiv, int ApplicantID = 0)
4121 {
4122 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4123 DataSet address = Qmortgage.GetAddressList(ApplicantID);
4124 List<AddressInfo> addresslist = DataTableHelper.CreateListFromTableForAll<AddressInfo>(address.Tables[0]).ToList<AddressInfo>();
4125
4126 ViewBag.ApplicantID = ApplicantID;
4127 ViewBag.AddressDiv = AddressDiv;
4128
4129 if (Request.IsAjaxRequest())
4130 {
4131 return Content(RenderPartialViewToUTFString(ControllerContext, ViewData, TempData, "_PartialAddressList", addresslist), "text/html");
4132 }
4133
4134 return PartialView("_PartialAddressList", addresslist);
4135 }
4136
4137 public ActionResult DeleteAddress(int addressID, string AddressDiv, int ApplicantID = 0)
4138 {
4139 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4140
4141 // delete address
4142 Qmortgage.DeleteAddress(addressID);
4143
4144 // bind address
4145 DataSet address = Qmortgage.GetAddressList(ApplicantID);
4146 List<AddressInfo> addresslist = DataTableHelper.CreateListFromTableForAll<AddressInfo>(address.Tables[0]).ToList<AddressInfo>();
4147
4148 ViewBag.ApplicantID = ApplicantID;
4149 ViewBag.AddressDiv = AddressDiv;
4150
4151 if (Request.IsAjaxRequest())
4152 {
4153 return Content(RenderPartialViewToUTFString(ControllerContext, ViewData, TempData, "_PartialAddressList", addresslist), "text/html");
4154 }
4155
4156 return PartialView("_PartialAddressList", addresslist);
4157
4158 }
4159
4160 #endregion
4161
4162 #region Commitments
4163 public ActionResult GetCommitments(string ClientRegistrationID = "0")
4164 {
4165 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4166 DataSet dscommitments = Qmortgage.GetCommitments(Convert.ToInt32(ClientRegistrationID));
4167 List<tblCurrentCommitments> commitments = DataTableHelper.CreateListFromTable<tblCurrentCommitments>(dscommitments.Tables[0]).ToList();
4168
4169 return PartialView("_PartialCommitmentList", commitments);
4170 }
4171
4172 [HttpPost]
4173 public ActionResult DeleteCurrentCommitment(string CurrentCommitmentsId)
4174 {
4175 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4176 Qmortgage.DeleteCommitments(int.Parse(CurrentCommitmentsId));
4177 return Json("", JsonRequestBehavior.AllowGet);
4178 }
4179 #endregion
4180
4181 #region Residential Mortgage
4182 public ActionResult GetResidentialMortgage(string ClientRegistrationID)
4183 {
4184 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4185 DataSet mortgage = Qmortgage.GetResidentialMortgage(Convert.ToInt32(ClientRegistrationID));
4186 List<tblResidentialMortgage> resmortgage = DataTableHelper.CreateListFromTableForAll<tblResidentialMortgage>(mortgage.Tables[0]).ToList();
4187
4188 return PartialView("_PartialResidentialMortgage", resmortgage);
4189 }
4190
4191 public ActionResult DeleteResidentialMortgage(string MortgageID)
4192 {
4193 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4194 Qmortgage.DeleteResidentialMortgage(int.Parse(MortgageID));
4195 return Json("", JsonRequestBehavior.AllowGet);
4196 }
4197
4198 //get applicants for [Residential Mortgage]
4199
4200 public JsonResult GetAddressesForMortgage(int ClientRegistrationID)
4201 {
4202 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4203 DataSet address = Qmortgage.GetApplicantsAddressForMortgage(ClientRegistrationID);
4204 List<AddressForMortgage> applicantaddress = DataTableHelper.CreateListFromTableForAll<AddressForMortgage>(address.Tables[0]).ToList();
4205 return Json(applicantaddress, JsonRequestBehavior.AllowGet);
4206
4207 }
4208
4209 #endregion
4210
4211 #region New Mortgage & Property Details
4212 public ActionResult GetNewMortgagePropertyDetails(string ClientRegistrationID)
4213 {
4214
4215
4216 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4217 DataSet newmortgage = Qmortgage.GetNewMortgagePropertyDetails(Convert.ToInt32(ClientRegistrationID));
4218 List<tblAdditional_Property_Info> newmortgagepropertydetails = DataTableHelper.CreateListFromTable<tblAdditional_Property_Info>(newmortgage.Tables[0]).ToList();
4219 return PartialView("_PartialNewMortgagePropertyDetails", newmortgagepropertydetails);
4220
4221 }
4222 public ActionResult DeleteNewMortgagePropertyDetails(string MortgageID)
4223 {
4224 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4225 Qmortgage.DeleteNewMortgagePropertyDetails(int.Parse(MortgageID));
4226 return Json("", JsonRequestBehavior.AllowGet);
4227 }
4228 #endregion
4229
4230 #region Investment Portfolio
4231
4232 public ActionResult GetInvestmentPortfolio(string ClientRegistrationID)
4233 {
4234
4235
4236 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4237 DataSet investmentportfolio = Qmortgage.GetInvestmentPortfolio(Convert.ToInt32(ClientRegistrationID));
4238 List<tblOther_Mortgages> invstmtportfolio = DataTableHelper.CreateListFromTable<tblOther_Mortgages>(investmentportfolio.Tables[0]).ToList();
4239 return PartialView("_PartialInvestmentPortfolio", invstmtportfolio);
4240
4241 }
4242 public ActionResult DeleteInvestmentPortfolio(string MortgageID)
4243 {
4244 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4245 Qmortgage.DeleteInvestmentPortfolio(int.Parse(MortgageID));
4246 return Json("", JsonRequestBehavior.AllowGet);
4247 }
4248 #endregion
4249
4250 #region Current Protection
4251 public ActionResult GetCurrentProtection(string ClientRegistrationID)
4252 {
4253 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4254 DataSet protec = Qmortgage.GetCurrentProtection(Convert.ToInt32(ClientRegistrationID));
4255 List<tblCurrent_Protection_Arrangements> protection = DataTableHelper.CreateListFromTable<tblCurrent_Protection_Arrangements>(protec.Tables[0]).ToList();
4256
4257 return PartialView("_PartialCurrentProtection", protection);
4258 }
4259 [HttpPost]
4260 public ActionResult DeleteCurrentProtection(string ProtectID)
4261 {
4262 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4263 Qmortgage.DeleteCurrentProtection(int.Parse(ProtectID));
4264 return Json("", JsonRequestBehavior.AllowGet);
4265 }
4266 #endregion.
4267
4268 #region Current Pension Investement
4269 public ActionResult GetCurrentPensionInvestments(string ClientRegistrationID)
4270 {
4271 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4272 DataSet pension = Qmortgage.GetCurrentPensionInvestments(Convert.ToInt32(ClientRegistrationID));
4273 List<tblCurrent_Pension_Investment_Arrangements> pensionInv = DataTableHelper.CreateListFromTable<tblCurrent_Pension_Investment_Arrangements>(pension.Tables[0]).ToList();
4274
4275 return PartialView("_PartialCurrentPensionInvestment", pensionInv);
4276 }
4277 [HttpPost]
4278 public ActionResult DeleteCurrentPensionInvestments(string ProtectID)
4279 {
4280 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4281 Qmortgage.DeleteCurrentPensionInvestments(int.Parse(ProtectID));
4282 return Json("", JsonRequestBehavior.AllowGet);
4283 }
4284 #endregion
4285
4286 //15 december 2014 start block
4287 #region Employment
4288 public ActionResult GetSelfEmployment(string ClientRegistrationID = "0")
4289 {
4290
4291 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4292 DataSet clientReg = Qmortgage.GetClientRegistrationID(Convert.ToInt32(ClientRegistrationID));
4293
4294
4295 // client registration
4296 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
4297
4298
4299 // self employment
4300 tblSelfEmployed[] selfEmployed = DataTableHelper.CreateListFromTable<tblSelfEmployed>(clientReg.Tables[4]).ToArray<tblSelfEmployed>();
4301
4302 // Other incom info
4303 tblOtherIncomeInformation[] otherIncomeInfo = DataTableHelper.CreateListFromTable<tblOtherIncomeInformation>(clientReg.Tables[5]).ToArray<tblOtherIncomeInformation>();
4304
4305
4306 // employment and incom
4307 tblEmploymentAndIncome[] employmentAndIncome = DataTableHelper.CreateListFromTable<tblEmploymentAndIncome>(clientReg.Tables[2]).ToArray<tblEmploymentAndIncome>();
4308
4309
4310
4311 List<Applicant> objApplicant = new List<Applicant>();
4312 objApplicant.Add(new Applicant() { ApplicantIDEmployment = employmentAndIncome.Where(a => a.ReferId == null).Select(s => s.EmploymentIncomeId).FirstOrDefault(), ApplicantId = selfEmployed.Where(a => a.ReferId == null).Select(s => s.SelfEmployedId).FirstOrDefault(), ApplicantName = clientRegistration[0].Forename });
4313 objApplicant.Add(new Applicant() { ApplicantIDEmployment = employmentAndIncome.Where(a => a.ReferId != null).Select(s => s.EmploymentIncomeId).FirstOrDefault(), ApplicantId = selfEmployed.Where(a => a.ReferId != null).Select(s => s.SelfEmployedId).FirstOrDefault(), ApplicantName = clientRegistration[1].Forename });
4314
4315
4316 ViewBag.Applicants = objApplicant;
4317
4318 Employment empl = new Employment
4319 {
4320 EmploymentIncome = employmentAndIncome,
4321 SelfEmployed = selfEmployed,
4322 OtherIncomeInfo = otherIncomeInfo,
4323 Count = clientRegistration[0].HasReference ? 1 : 0,
4324 ApplicantInfo = objApplicant
4325
4326 };
4327
4328
4329
4330 //return PartialView("_PartialSelfEmploymentList", selfEmployment);
4331 return PartialView("_PartialEmployment", empl);
4332 }
4333
4334 public ActionResult GetEmploymentAndIncome(string ClientRegistrationID = "0")
4335 {
4336 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4337 DataSet clientReg = Qmortgage.GetClientRegistrationID(Convert.ToInt32(ClientRegistrationID));
4338
4339
4340 // client registration
4341 tblClientRegistration[] clientRegistration = DataTableHelper.CreateListFromTable<tblClientRegistration>(clientReg.Tables[0]).ToArray<tblClientRegistration>();
4342
4343
4344 // self employment
4345 tblSelfEmployed[] selfEmployed = DataTableHelper.CreateListFromTable<tblSelfEmployed>(clientReg.Tables[4]).ToArray<tblSelfEmployed>();
4346
4347 // Other incom info
4348 tblOtherIncomeInformation[] otherIncomeInfo = DataTableHelper.CreateListFromTable<tblOtherIncomeInformation>(clientReg.Tables[5]).ToArray<tblOtherIncomeInformation>();
4349
4350
4351 // employment and incom
4352 tblEmploymentAndIncome[] employmentAndIncome = DataTableHelper.CreateListFromTable<tblEmploymentAndIncome>(clientReg.Tables[2]).ToArray<tblEmploymentAndIncome>();
4353
4354
4355
4356 List<Applicant> objApplicant = new List<Applicant>();
4357 objApplicant.Add(new Applicant() { ApplicantIDEmployment = employmentAndIncome.Where(a => a.ReferId == null).Select(s => s.EmploymentIncomeId).FirstOrDefault(), ApplicantId = selfEmployed.Where(a => a.ReferId == null).Select(s => s.SelfEmployedId).FirstOrDefault(), ApplicantName = clientRegistration[0].Forename });
4358 objApplicant.Add(new Applicant() { ApplicantIDEmployment = employmentAndIncome.Where(a => a.ReferId != null).Select(s => s.EmploymentIncomeId).FirstOrDefault(), ApplicantId = selfEmployed.Where(a => a.ReferId != null).Select(s => s.SelfEmployedId).FirstOrDefault(), ApplicantName = clientRegistration[1].Forename });
4359
4360
4361 ViewBag.Applicants = objApplicant;
4362
4363 Employment empl = new Employment
4364 {
4365 EmploymentIncome = employmentAndIncome,
4366 SelfEmployed = selfEmployed,
4367 OtherIncomeInfo = otherIncomeInfo,
4368 Count = clientRegistration[0].HasReference ? 1 : 0,
4369 ApplicantInfo = objApplicant
4370
4371 };
4372
4373
4374
4375 //return PartialView("_PartialSelfEmploymentList", selfEmployment);
4376 return PartialView("_PartialEmployment", empl);
4377 }
4378 [HttpPost]
4379 public ActionResult DeleteEmploymentIncome(string EmploymentIncomeId)
4380 {
4381 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4382 Qmortgage.DeleteEmploymentIncome(int.Parse(EmploymentIncomeId));
4383 return Json("", JsonRequestBehavior.AllowGet);
4384 }
4385 [HttpPost]
4386 public ActionResult DeleteSelfEmployment(string SelfEmployedId, string TypeOfEmployment)
4387 {
4388 Q_MortgageFactFind Qmortgage = new Q_MortgageFactFind();
4389 Qmortgage.DeleteSelfEmployment(int.Parse(SelfEmployedId), TypeOfEmployment);
4390 return Json("", JsonRequestBehavior.AllowGet);
4391 }
4392 #endregion
4393 //end block
4394
4395 #endregion
4396
4397
4398
4399 public ActionResult LogOut()
4400 {
4401 Session.Clear();
4402 Session.Abandon();
4403 Session.RemoveAll();
4404 CookieWrapper.ClientRegistrationID = 0;
4405 CookieWrapper.UserId = 0;
4406 Response.Cookies.Clear();
4407 Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
4408 ViewBag.FormAction = "DoLogin";
4409
4410 return RedirectToAction("Index", "Home");
4411 }
4412
4413 #endregion
4414
4415 #region [Unsubscribed List]
4416 public ActionResult UnsubscribeEmails(int contactId, int type)
4417 {
4418 WebUtility.UnsubscribeEmail(contactId, type);
4419 ViewBag.ContactId = contactId;
4420 ViewBag.Type = type;
4421 return View();
4422 }
4423 #endregion [Unsubscribed List]
4424
4425
4426 public string RenderPartialViewToUTFString(ControllerContext controllerContextontrollerContext,
4427ViewDataDictionary viewData, TempDataDictionary tempData, string viewName, object myModel)
4428 {
4429 if (string.IsNullOrEmpty(viewName))
4430 viewName = controllerContextontrollerContext.RouteData.GetRequiredString("action");
4431
4432 viewData.Model = myModel;
4433
4434 using (var sw = new StringWriter())
4435 {
4436 var viewResult = ViewEngines.Engines.FindPartialView(controllerContextontrollerContext, viewName);
4437 var viewContext = new ViewContext(controllerContextontrollerContext, viewResult.View, viewData, tempData, sw);
4438 viewResult.View.Render(viewContext, sw);
4439
4440 var s = sw.GetStringBuilder().ToString();
4441 return s;
4442 }
4443 }
4444
4445
4446 #region [Link mortgage ]
4447 public JsonResult LinkMortgagePopUp(List<ContactMail> ContactArray)
4448 {
4449 try
4450 {
4451 List<LinkMortgageDetail> lstContactDetails = new List<LinkMortgageDetail>();
4452 if (Session["LoggedInUserId"] == null)
4453 {
4454 return Json("SessionExpire", JsonRequestBehavior.AllowGet);
4455 }
4456 else if (ContactArray == null || ContactArray.Count <= 0)
4457 {
4458 return Json("noRecord", JsonRequestBehavior.AllowGet);
4459 }
4460 else
4461 {
4462 var contactIds = ContactArray.Select(x => x.contactid).Distinct();
4463 lstContactDetails = ctx.tblcontacts.Where(x => contactIds.Contains(x.contactid)).Select(x => new LinkMortgageDetail
4464 {
4465 ContactName = (x.firstname ?? "") + " " + (x.lastname ?? ""),
4466 ContactEmail = x.email ?? "",
4467 BrokerId = x.broker ?? 0,
4468 ContactId = x.contactid
4469 }).ToList();
4470 }
4471
4472 return Json(lstContactDetails, JsonRequestBehavior.AllowGet);
4473 }
4474 catch (Exception ex)
4475 {
4476 Helper.ErrorLog(ex.InnerException, "HomeController", "LinkMortgagePopUp", ex.Message);
4477 return Json("Exception", JsonRequestBehavior.AllowGet);
4478 }
4479 }
4480
4481 #endregion[Link Mortgage]
4482
4483 public JsonResult CheckInsuranceBroker()
4484 {
4485 Q_Application QApplication = new Q_Application();
4486 int userId = Convert.ToInt32(Session["LoggedInUserId"] ?? "0");
4487 bool IsInsuranceBrokerLogin = QApplication.IsInsuranceBroker(userId);
4488 return Json(IsInsuranceBrokerLogin, JsonRequestBehavior.AllowGet);
4489 }
4490
4491 #region[Intellicalc Integration Guide]
4492 public JsonResult SaveBasicDetialsForIntellicalc(string compname, string contname, string tel, string email)
4493 {
4494 try
4495 {
4496 int status = 0;
4497 int Id = 0;
4498 Q_Application QApplication = new Q_Application();
4499 bool Isduplicate = Qclient.DuplicateEmailCheck(email, "");
4500 if (!Isduplicate)
4501 {
4502 Id = QApplication.SaveBasicIntellicalcDetails(compname, contname, tel, email);
4503 if (Id > 0)
4504 {
4505 var _templateInfo = "";
4506 var _mailTemplate = "";
4507 try
4508 {
4509 MailChimp.MailChimpManager mc = new MailChimp.MailChimpManager(System.Configuration.ConfigurationManager.AppSettings["MailChimpApikey"]);
4510 var _MtemplateInfo = mc.GetTemplateInformation(247649);
4511 _templateInfo = _MtemplateInfo != null ? _MtemplateInfo.Source : "";
4512 }
4513 catch (Exception ex)
4514 {
4515 Helper.ErrorLog(ex.InnerException, "HomeController", "SaveBasicDetailsForIntellicalc", ex.Message);
4516 }
4517 if (string.IsNullOrWhiteSpace(_templateInfo))
4518 {
4519 _mailTemplate = "Dear Conor/Nick, <br /><br />";
4520 _mailTemplate += "Please find below the new Intellicalc details.<br />";
4521 _mailTemplate += "Company Name: " + compname + "<br />";
4522 _mailTemplate += "Contact Name: " + contname + "<br />";
4523 _mailTemplate += "Telephone: " + tel + "<br />";
4524 _mailTemplate += "Email: " + email + "<br /><br /><br />";
4525 _mailTemplate += "Regards: <br />";
4526 _mailTemplate += "Administrator <br />";
4527 _mailTemplate += "OCC Finance<br />";
4528 }
4529 else
4530 {
4531
4532 StringBuilder _tempate = new StringBuilder();
4533
4534 _tempate.Append(_templateInfo);
4535 _tempate = _tempate
4536 .Replace("*|MC:SUBJECT|*", "")
4537 .Replace("*|CompanyName|*", compname)
4538 .Replace("*|ContactName|*", contname)
4539 .Replace("*|Telephone|*", tel)
4540 .Replace("*|Email|*", email);
4541
4542 _mailTemplate = _tempate.ToString();
4543 }
4544
4545
4546 List<ManDRILLModel> _mandrillOBJ = new List<ManDRILLModel>();
4547
4548 var _mailDrilEmails = new List<EmailAddress>();
4549 EmailAddress objEm = new EmailAddress();
4550 objEm.email = "synapsemsteam@gmail.com";
4551 objEm.name = "";
4552 _mailDrilEmails.Add(objEm);
4553
4554 EmailAddress objEm1 = new EmailAddress();
4555 objEm1.email = "synapsemsteam@gmail.com";
4556 objEm1.name = "";
4557 _mailDrilEmails.Add(objEm1);
4558
4559 //Man DRILL ********************************************************************
4560
4561 var domain = "occfinance.com";
4562 EmailMessage message = new EmailMessage();
4563 var _mandrillMessage = new List<EmailMessage>();
4564
4565 message.to = _mailDrilEmails;
4566 message.html = _mailTemplate;
4567 message.from_email = ConfigurationManager.AppSettings["SMTP_FROM"].ToString();
4568 message.from_name = "OCC";
4569 message.subject = "New Intellicalc Request";
4570 message.inline_css = true;
4571 message.signing_domain = domain;
4572 message.AddHeader("X-MC-SigningDomain", domain);
4573 message.AddHeader("X-MC-TrackingDomain", domain);
4574 _mandrillMessage.Add(message);
4575
4576 //********************************************************************************
4577
4578 // Manage The ManDRILLModel - 25-07-2014
4579
4580 var objMAN = new ManDRILLModel();
4581 objMAN.contactId = 0;
4582 objMAN.financeid = 0;
4583 objMAN.mailcontent = _mailTemplate;
4584 objMAN.MandrillMSG = message;
4585 objMAN.IsAppContact = false;
4586
4587 objMAN.notemsg = "";
4588
4589 _mandrillOBJ.Add(objMAN);
4590
4591
4592 WebUtility.SendMailViaManDRILL(_mandrillOBJ, 0);
4593
4594 //------------------------------------------------------------
4595
4596 status = 1;
4597
4598 //download file
4599
4600 string sFileName = System.IO.Path.GetRandomFileName();
4601 string sGenName = "templateforlastnote.html";
4602
4603 //YOu could omit these lines here as you may
4604 //not want to save the textfile to the server
4605 //I have just left them here to demonstrate that you could create the text file
4606 using (System.IO.StreamWriter SW = new System.IO.StreamWriter(
4607 Server.MapPath("~/templateforlastnote.html")))
4608 {
4609 SW.WriteLine("~/templateforlastnote.html");
4610 SW.Close();
4611 }
4612
4613 System.IO.FileStream fs = null;
4614 fs = System.IO.File.Open(Server.MapPath("~/templateforlastnote.html"), System.IO.FileMode.Open);
4615 byte[] btFile = new byte[fs.Length];
4616 fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
4617 fs.Close();
4618 Response.AddHeader("Content-disposition", "attachment; filename=" +
4619 sGenName);
4620 Response.ContentType = "text/html";
4621 Response.BinaryWrite(btFile);
4622 Response.End();
4623 }
4624 }
4625 return Json(new
4626 {
4627 Isduplicate = Isduplicate,
4628 status = status
4629
4630 });
4631 }
4632 catch (Exception ex)
4633 {
4634 Helper.ErrorLog(ex.InnerException, "HomeController", "SaveBasicDetailsForIntellicalc", ex.Message);
4635 return Json(new
4636 {
4637 Isduplicate = false,
4638 status = 0
4639
4640 });
4641 }
4642
4643 }
4644
4645 #endregion
4646
4647 }
4648}