public ActionResult SaveQuoteRequest(int nServiceId, GetQuoteInfo viewModel, FormCollection fCollection)
        {
            String strActionName     = String.Empty;
            String strControllerName = String.Empty;

            if (ModelState.IsValid)
            {
                viewModel.ServiceId = nServiceId;
                ServiceInteractiveController controller = new ServiceInteractiveController();
                bool bRtnval = controller.SetCustomerRequestInfo(viewModel);
                if (!bRtnval)
                {
                    strActionName     = "Index";
                    strControllerName = "Error";
                }
                else
                {
                    strActionName            = "Electrician";
                    strControllerName        = "EnterData";
                    bIsSaveRequestSuccessful = true;
                }
            }
            else
            {
                strControllerName = "Electrician";
                strActionName     = "EnterData";
            }
            return(RedirectToAction(strActionName, strControllerName));
        }
Exemplo n.º 2
0
        private void CreateHappyHutUsers()
        {
            try
            {
                List <HappyHutUserInfo> lstHappyHutUsers = new List <HappyHutUserInfo>();
                if (lstCreateUser != null && lstCreateUser.Count > 0)
                {
                    foreach (String strEmail in lstCreateUser)
                    {
                        if (CreateUser(strEmail))
                        {
                            GetQuoteInfo quoteInfo = lstQuotes.Where(x => x.Email.ToLower().Equals(strEmail.ToLower())).FirstOrDefault();

                            EmailUtil utilObject = new EmailUtil()
                            {
                                ToEmail = strEmail,
                                ToName  = String.Format("{0} {1}", quoteInfo.FirstName, quoteInfo.LastName),
                                Subject = "Login information for HappyHut!!!",
                            };
                            //TODO:: Add Body Template
                            bool emailSent = EmailUtil.Instance.SendEmail(utilObject);
                            if (!emailSent)
                            {
                                ApplicationLog.Instance.WriteWarning(String.Format("Email not sent to {0} for service login", strEmail));
                                //TODO:: Send email to [email protected] && [email protected]
                            }

                            if (quoteInfo != null)
                            {
                                HappyHutUserInfo inf = new HappyHutUserInfo()
                                {
                                    Username     = strEmail,
                                    FirstName    = quoteInfo.FirstName,
                                    LastName     = quoteInfo.LastName,
                                    Email        = quoteInfo.Email,
                                    MobileNumber = String.Empty,
                                    AddressLine1 = String.Empty,
                                    AddressLine2 = String.Empty,
                                    CityId       = quoteInfo.CityId,
                                    IsFirstLogin = true,
                                };
                                lstHappyHutUsers.Add(inf);
                            }
                        }
                    }
                }

                if (lstHappyHutUsers != null && lstHappyHutUsers.Count > 0)
                {
                    client = new DatabaseClass();
                    client.SetHappyHutUsersInfos(lstHappyHutUsers, null);
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.Instance.WriteException(ex);
            }
        }
Exemplo n.º 3
0
 public ActionResult SaveQuoteRequest(int nServiceId, GetQuoteInfo viewModel, FormCollection fCollection)
 {
     if (ModelState.IsValid)
     {
         viewModel.AdditionalInfo = !String.IsNullOrEmpty(viewModel.AdditionalInfo) ? String.Format("{0},{1}", viewModel.AdditionalInfo, fCollection["ddnNumberOfBedRooms"]) : fCollection["ddnNumberOfBedRooms"];
         viewModel.ServiceId      = nServiceId;
         ServiceInteractiveController controller = new ServiceInteractiveController();
         controller.SetCustomerRequestInfo(viewModel);
     }
     return(View());
 }
        public bool SetCustomerRequestInfo(GetQuoteInfo request)
        {
            bool bFlag = false;

            try
            {
                bFlag = client.SetCustomerRequestInfo(request);
            }
            catch (Exception ex)
            {
                ApplicationLog.Instance.WriteException(ex);
            }
            return(bFlag);
        }
Exemplo n.º 5
0
        public bool SetCustomerRequestInfo(GetQuoteInfo inf, HappyHutDataBaseEntities Entities = null)
        {
            bool     bFlag = false;
            DateTime now   = DateTime.UtcNow;
            HappyHutDataBaseEntities entities = null;

            try
            {
                entities = Entities == null ? new HappyHutDataBaseEntities() : Entities;

                GetQuoteRequest dat = entities.GetQuoteRequests.SingleOrDefault(x => x.Id.Equals(inf.Id));

                if (dat == null)
                {
                    dat = new GetQuoteRequest()
                    {
                        Id       = Guid.NewGuid(),
                        CreateDt = now,
                    };
                    entities.GetQuoteRequests.Add(dat);
                }
                dat.FirstName      = !String.IsNullOrEmpty(inf.FirstName) ? inf.FirstName : String.Empty;
                dat.LastName       = !String.IsNullOrEmpty(inf.LastName) ? inf.LastName : String.Empty;
                dat.Email          = !String.IsNullOrEmpty(inf.Email) ? inf.Email : String.Empty;
                dat.MobileNumber   = !String.IsNullOrEmpty(inf.MobileNumber) ? inf.MobileNumber : String.Empty;
                dat.ServiceId      = inf.ServiceId;
                dat.IsEmailSent    = inf.IsEmailSent;
                dat.EmailSentDt    = inf.EmailSentDt;
                dat.PreferredDate  = inf.PreferredDate;
                dat.PreferredTime  = inf.PreferredTime;
                dat.AdditionalInfo = !String.IsNullOrEmpty(inf.AdditionalInfo) ? inf.AdditionalInfo : String.Empty;
                dat.LastUpdateDt   = now;


                if (Entities == null)
                {
                    entities.SaveChanges();
                }
                bFlag = true;
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    ApplicationLog.Instance.WriteError(String.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                                     eve.Entry.Entity.GetType().Name, eve.Entry.State));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        ApplicationLog.Instance.WriteError(String.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                                         ve.PropertyName, ve.ErrorMessage));
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.Instance.WriteException(ex);
            }
            finally
            {
                if (Entities == null)
                {
                    entities.Dispose();
                }
            }
            return(bFlag);
        }