public ActionResult ApproveEvents(int?Id)
        {
            if (Id != 0)
            {
                var location = _LocationService.GetLocations().Where(l => l.LocationId == Id).FirstOrDefault();

                if (location != null)
                {
                    location.IsApproved = true;
                    location.Status     = EnumValue.GetEnumDescription(EnumValue.LocationStatus.Approved);
                    _LocationService.UpdateLocation(location);
                    CommonCls.SendMailToUser("", "", "");
                }
                TempData["ShowMessage"] = "success";
                TempData["MessageBody"] = " Location approved  successfully.";
                return(RedirectToAction("Index"));
            }



            else
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = " Location not found. ";
                return(RedirectToAction("Details", new { Id = Id }));
            }
        }
Ejemplo n.º 2
0
        private IList <PropertyModell> GetData(string Type, string dbName = "", string userid = "")
        {
            List <PropertyModel> PropertList = new List <PropertyModel>();

            if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Residential))
            {
                PropertList = _ResidentialService.GetResidentials(dbName, userid);
            }
            else if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Commercial))
            {
                PropertList = _CommercialService.GetCommercials(dbName, userid);
            }
            else if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Condo))
            {
                PropertList = _CondoService.GetCondos(dbName, userid);
            }
            else
            {
                PropertList = _ResidentialService.GetResidentials(dbName, userid);
            }
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <PropertyModel, PropertyModell>();
            });

            IMapper mapper = config.CreateMapper();

            foreach (var item in PropertList)
            {
                var dest = mapper.Map <PropertyModel, PropertyModell>(item);
                allEmployee.Add(dest);
            }
            return(allEmployee);
        }
        // GET: /Account/ReverifyAccountMail
        public JsonResult ReverifyAccountMail(RegisterModel registerModel)
        {
            int result = -1;

            try
            {
                var userInfo = base._userService.GetUserByName(registerModel.Email);
                if (userInfo != null)
                {
                    if (userInfo.IsActive)
                    {
                        result = 2;
                    }
                    else
                    {
                        //Start : Add Job for Send Welcome Email
                        JobScheduler.WelcomeEmailJob(userInfo.UserId.ToString(), EnumValue.GetEnumDescription(EnumValue.EmailType.ReverifyAccount));
                        result = 1;
                        //End : Add Job for Send Welcome Email
                    }
                    return(Json(Infrastructure.CommonClass.CreateMessage("success", result), JsonRequestBehavior.AllowGet));
                }
                return(Json(Infrastructure.CommonClass.CreateMessage("error", "This email id does not exist. Please try again."), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                string   ErrorMsg = ex.Message.ToString();
                ErrorLog errorlog = new ErrorLog();
                errorlog.LogError(ex);
                return(Json(Infrastructure.CommonClass.CreateMessage("error", "Something went wrong.Please try later."), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult RejectRequest(int jobRequestId)
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("LogOn", "Account"));
            }
            JobRequest jobRequest = _RequestService.GetRequest(jobRequestId);

            if (jobRequest != null)
            {
                jobRequest.RequestStatus = EnumValue.GetEnumDescription(EnumValue.RequestStatus.Declined);
                _RequestService.UpdateRequest(jobRequest);

                AgencyJob agencyjob = _AgencyJobService.GetAgencyJobByJobRequest(jobRequestId);
                if (agencyjob != null)
                {
                    _AgencyJobService.DeleteAgencyJob(agencyjob);
                }
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 5
0
        public JsonReturnModel getAttendence(StudentAttendence StudentAttendence)
        {
            List <AttendenceModel> attendenceList = new List <AttendenceModel>();
            var Customer = _CustomerService.GetCustomer(StudentAttendence.CustomerId).CustomerType;

            if (Customer != null)
            {
                if (Customer == StudentAttendence.CustomerType)
                {
                    if (Customer == EnumValue.GetEnumDescription(EnumValue.CustomerType.Student) || Customer == EnumValue.GetEnumDescription(EnumValue.CustomerType.Parent))
                    {
                        var attendences = _AttendenceService.GetAttendences().Where(a => (a.AttendenceDate >= StudentAttendence.StartDate && a.AttendenceDate <= StudentAttendence.EndDate) && a.CustomerId == StudentAttendence.CustomerId).ToList();
                        if (attendences.Count() > 0)
                        {
                            foreach (var item in attendences)
                            {
                                if (item.Status == EnumValue.GetEnumDescription(EnumValue.AttendenceStatus.Present))
                                {
                                    Mapper.CreateMap <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>();
                                    Onlo.Models.AttendenceModel Attendence = Mapper.Map <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>(item);
                                    attendenceList.Add(Attendence);
                                }
                            }
                        }
                    }
                    else
                    {
                        var CustomerList = _CustomerService.GetCustomers().Where(c => c.ParentId == StudentAttendence.CustomerId).ToList();
                        if (CustomerList.Count() > 0)
                        {
                            var CustomerIds = CustomerList.Select(s => s.CustomerId).ToList();
                            foreach (var CustomerId in CustomerIds)
                            {
                                var studentAttendence = _AttendenceService.GetAttendences().Where(a => a.CustomerId == CustomerId && a.AttendenceDate == StudentAttendence.StartDate).FirstOrDefault();
                                if (studentAttendence != null)
                                {
                                    Mapper.CreateMap <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>();
                                    Onlo.Models.AttendenceModel Attendence = Mapper.Map <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>(studentAttendence);
                                    var studentDetail = _CustomerService.GetCustomer(studentAttendence.CustomerId);
                                    Attendence.StudentName = studentDetail.Name;
                                    Attendence.StudentCode = studentDetail.StudentCode;
                                    Attendence.ProfilePath = studentDetail.PhotoPath;
                                    Attendence.EmailId     = studentDetail.EmailId;
                                    attendenceList.Add(Attendence);
                                }
                            }
                        }
                    }
                    return(CommonCls.CreateMessage("success", attendenceList));
                }
                else
                {
                    return(CommonCls.CreateMessage("error", "This Customer doesnot exist in this customer type."));
                }
            }
            else
            {
                return(CommonCls.CreateMessage("success", "No attendence found."));
            }
        }
Ejemplo n.º 6
0
 public ActionResult SaveAppointment(string FirstName, string LastName, string Email, string PhoneNumber, string AppointmentDate, string AppointmentTime, string Notes, string UserType)
 {
     try
     {
         using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["DataBase"].ConnectionString))
         {
             string sqlQuery     = @"Insert Into tbl_ScheduleAppointment (FirstName,LastName,[Email],[PhoneNumber],AppointmentDate,AppointmentTime,Notes,UserType) Values (@FirstName,@LastName,@Email,@PhoneNumber,@AppointmentDate,@AppointmentTime,@Notes,@UserType);SELECT CAST(SCOPE_IDENTITY() as int)";
             int    rowsAffected = db.Query <int>(sqlQuery, new
             {
                 FirstName,
                 LastName,
                 Email,
                 PhoneNumber,
                 AppointmentDate,
                 AppointmentTime,
                 Notes,
                 UserType
             }).SingleOrDefault();
         }
         CommonClass.SendMailToAdmin(EnumValue.GetEnumDescription(EnumValue.EmailType.Appointment), FirstName + " " + LastName, Email, PhoneNumber, AppointmentDate, AppointmentTime, Notes, UserType);
         CommonClass.SendMailToUser(EnumValue.GetEnumDescription(EnumValue.EmailType.Appointment), FirstName + " " + LastName, Email, AppointmentDate, AppointmentTime);
         return(Json("Success", JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json("Error", JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 7
0
        private IList <PropertyModell> GetAllFavourite(int ID)
        {
            List <PropertyModel> PropertList = new List <PropertyModel>();

            var           query        = "Select MLSID,Type from [tbl_Favourite] where ID=@ID  group by Type,MLSID";
            var           result       = db.Query <tbl_Favourite>(query, new { ID = ID }).ToList();
            List <string> Residentials = new List <string>();
            List <string> Commercials  = new List <string>();
            List <string> Condos       = new List <string>();

            foreach (var item in result)
            {
                if (item.Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Residential))
                {
                    Residentials.Add(item.MLSID);
                }
                else if (item.Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Commercial))
                {
                    Commercials.Add(item.MLSID);
                }
                else if (item.Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Condo))
                {
                    Condos.Add(item.MLSID);
                }
            }


            PropertList = _ResidentialService.GetResidentials().Where(c => Residentials.Contains(c.MLS)).ToList();
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <PropertyModel, PropertyModell>();
            });

            IMapper mapper = config.CreateMapper();

            foreach (var item in PropertList)
            {
                var dest = mapper.Map <PropertyModel, PropertyModell>(item);
                allFav.Add(dest);
            }

            PropertList = _CommercialService.GetCommercials().Where(c => Commercials.Contains(c.MLS)).ToList();

            foreach (var item in PropertList)
            {
                var dest = mapper.Map <PropertyModel, PropertyModell>(item);
                allFav.Add(dest);
            }

            PropertList = _CondoService.GetCondos().Where(c => Condos.Contains(c.MLS)).ToList();

            foreach (var item in PropertList)
            {
                var dest = mapper.Map <PropertyModel, PropertyModell>(item);
                allFav.Add(dest);
            }
            return(allFav);
        }
Ejemplo n.º 8
0
        public HttpResponseMessage GetAllProperty(string PropertyTypeStatus)
        {
            int PropertyStatusId = 0;

            try
            {
                if (PropertyTypeStatus == "" || PropertyTypeStatus == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("error", "Property Type Status cannot be blank."), Configuration.Formatters.JsonFormatter));
                }
                if (PropertyTypeStatus == EnumValue.GetEnumDescription(EnumValue.PropertySatus.ExclusiveCommercial))
                {
                    PropertyStatusId = (int)EnumValue.PropertySatus.ExclusiveCommercial;
                }
                else if (PropertyTypeStatus == EnumValue.GetEnumDescription(EnumValue.PropertySatus.ExclusiveResidential))
                {
                    PropertyStatusId = (int)EnumValue.PropertySatus.ExclusiveResidential;
                }
                else if (PropertyTypeStatus == EnumValue.GetEnumDescription(EnumValue.PropertySatus.NewHotListingCommercial))
                {
                    PropertyStatusId = (int)EnumValue.PropertySatus.NewHotListingCommercial;
                }
                else if (PropertyTypeStatus == EnumValue.GetEnumDescription(EnumValue.PropertySatus.NewHotListingResidential))
                {
                    PropertyStatusId = (int)EnumValue.PropertySatus.NewHotListingResidential;
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("error", "Property Type Status is incorrect."), Configuration.Formatters.JsonFormatter));
                }
                //int? PropertyTypeStatusValue = CheckPropertyStatus(PropertyTypeStatus);


                if (PropertyStatusId != 0)
                {
                    var Properties = _PropertyService.GetPropertys().Where(c => c.PropertyStatusId == PropertyStatusId).OrderByDescending(c => c.PropertyId);
                    var models     = new List <PropertyModel>();
                    Mapper.CreateMap <CommunicationApp.Entity.Property, CommunicationApp.Web.Models.PropertyModel>();
                    foreach (var Property in Properties)
                    {
                        PropertyModel PropertyModel = new Web.Models.PropertyModel();
                    }

                    return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("success", models), Configuration.Formatters.JsonFormatter));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("error", "No record found"), Configuration.Formatters.JsonFormatter));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.OK, Common.CreateMessage("error", "Please try later."), Configuration.Formatters.JsonFormatter));
            }
        }
Ejemplo n.º 9
0
        public JsonResult UpdateAgent(string PropertyId, string IsCheked)
        {
            try
            {
                var Status = "";
                var Agent  = _AgentService.GetAgent(Convert.ToInt32(PropertyId));
                if (Agent != null)
                {
                    if (IsCheked == "Yes")
                    {
                        if (Agent.IsActive == false)
                        {
                            Agent.IsActive = true;
                            Status         = "Yes";
                            PropertyModel PropertyModel = new Web.Models.PropertyModel();
                            if (Agent.AgentStatusId == (int)EnumValue.AgentSatus.AgentAvailable)
                            {
                                PropertyModel.PropertyType = EnumValue.GetEnumDescription(EnumValue.AgentSatus.AgentAvailable);
                            }
                            else if (Agent.AgentStatusId == (int)EnumValue.AgentSatus.AgentRequired)
                            {
                                PropertyModel.PropertyType = EnumValue.GetEnumDescription(EnumValue.AgentSatus.AgentRequired);
                            }
                            PropertyModel.MLS = Agent.MLS;
                            PropertyModel.PropertyTypeStatus = "Open House property";
                            var Customer  = _CustomerService.GetCustomer(Convert.ToInt32(Agent.CustomerId));
                            var FirstName = Customer.FirstName + " " + Customer.MiddleName + " " + Customer.LastName;
                            if (Customer != null)
                            {
                                SendMailToUser(FirstName, Customer.EmailId, PropertyModel);
                            }
                        }
                    }
                    else if (IsCheked == "No")
                    {
                        Agent.IsActive = false;
                        Status         = "No";
                    }

                    _AgentService.UpdateAgent(Agent);
                }

                return(Json(Status));
            }

            catch (Exception ex)
            {
                ErrorLogging.LogError(ex);
                return(Json("error"));
            }
        }
        public JsonResult IsLinkExpire(string requestId, string page)
        {
            try
            {
                var emailVerification = _emailVerificationService.GetEmailVerification(requestId); //Here requestid is emailVerificationId
                if (emailVerification == null)
                {
                    return(Json(Infrastructure.CommonClass.CreateMessage("error", "RecordNoFound")));
                }
                if (page == "resetpassword")
                {
                    if (emailVerification != null && emailVerification.EmailType != EnumValue.GetEnumDescription(EnumValue.EmailType.ResetPassword))
                    {
                        return(Json(Infrastructure.CommonClass.CreateMessage("error", "RecordNoFound")));
                    }
                }
                else if (page == "verifyaccount")
                {
                    if (emailVerification != null &&
                        emailVerification.EmailType != EnumValue.GetEnumDescription(EnumValue.EmailType.WelcomeEmail) &&
                        emailVerification.EmailType != EnumValue.GetEnumDescription(EnumValue.EmailType.ReverifyAccount))
                    {
                        return(Json(Infrastructure.CommonClass.CreateMessage("error", "RecordNoFound")));
                    }
                }
                if (emailVerification.IsActive == false || emailVerification.IsOperationDone == true) //Expire
                {
                    return(Json(Infrastructure.CommonClass.CreateMessage("error", "Expired")));
                }
                var expireDateTime = emailVerification.CreatedOn.AddMinutes(emailVerification.ActiveForMinute);
                var serverDateTime = _userService.GetServerDateTime();
                if (expireDateTime <= serverDateTime)
                {
                    emailVerification.IsActive = false; //Deactivate it
                    _emailVerificationService.UpdateEmailVerification(emailVerification);
                    return(Json(Infrastructure.CommonClass.CreateMessage("error", "Expired")));
                }

                return(Json(Infrastructure.CommonClass.CreateMessage("success", emailVerification.UserId)));
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();

                ErrorLog errorlog = new ErrorLog();
                errorlog.LogError(ex);
                return(Json(Infrastructure.CommonClass.CreateMessage("error", "RecordNoFound")));
            }
        }
        public HttpResponseMessage ForgotPassword([FromBody] ForgetPasswordsModel usermodel)
        {
            try
            {
                if (usermodel.CustomerType == "" || usermodel.CustomerType == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer Type is blank."), Configuration.Formatters.JsonFormatter));
                }
                if (usermodel.CustomerType != EnumValue.GetEnumDescription(EnumValue.CustomerType.Customer) && usermodel.CustomerType != EnumValue.GetEnumDescription(EnumValue.CustomerType.ServiceProvider))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Wrong Customer Type."), Configuration.Formatters.JsonFormatter));
                }
                if (usermodel.EmailId == "" || usermodel.CustomerType == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer Type is blank."), Configuration.Formatters.JsonFormatter));
                }
                var customer = _CustomerService.GetCustomers().Where(x => x.EmailId == usermodel.EmailId && x.CustomerType == usermodel.CustomerType).FirstOrDefault();
                if (customer != null)
                {
                    var user = _UserService.GetUserById(Convert.ToInt32(customer.UserId));
                    if (user != null)
                    {
                        if (!customer.IsActive)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "User is deactivated."), Configuration.Formatters.JsonFormatter));
                        }
                        //Send Email to User
                        string Password = SecurityFunction.DecryptString(user.Password);
                        SendMailToUser(customer.FirstName + " " + customer.LastName, usermodel.EmailId, Password);

                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", "Password has been sent to your email. Please check your email."), Configuration.Formatters.JsonFormatter));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "User is not found."), Configuration.Formatters.JsonFormatter));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Incorrect email id."), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Please try later."), Configuration.Formatters.JsonFormatter));
            }
        }
        public JsonResult Register(RegisterModel registerModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Mapper.CreateMap <RegisterModel, User>();
                    User user = Mapper.Map <RegisterModel, User>(registerModel);
                    user.UserName = registerModel.Email;
                    user.EmailId  = registerModel.Email;

                    //Check Email already exist
                    User isEmailFound = _userService.GetUserByName(user.EmailId);
                    if (isEmailFound != null)
                    {
                        return(Json(Infrastructure.CommonClass.CreateMessage("error", "Email already in use.")));
                    }

                    //Insert User
                    user.Password = SecurityFunction.EncryptString(user.Password);
                    user.IsActive = false;
                    var userResult = _userService.InsertUser(user);
                    //End : Insert User

                    if (userResult != null)
                    {
                        //Start : Add Job for Send Welcome Email
                        JobScheduler.WelcomeEmailJob(user.UserId.ToString(), EnumValue.GetEnumDescription(EnumValue.EmailType.WelcomeEmail));
                        //End : Add Job for Send Welcome Email

                        //return Json(Infrastructure.CommonClass.CreateMessage("success", "Successfully registered. Please check your email for account verification."));
                        return(Json(Infrastructure.CommonClass.CreateMessage("success", "Successfully registered. Please check your email.")));
                    }
                    else
                    {
                        return(Json(Infrastructure.CommonClass.CreateMessage("error", "There is problem while saving data.")));
                    }
                }
                return(Json(Infrastructure.CommonClass.CreateMessage("error", "Please fill all the fields")));
            }
            catch (Exception ex)
            {
                string   ErrorMsg = ex.Message.ToString();
                ErrorLog errorlog = new ErrorLog();
                errorlog.LogError(ex);
                return(Json(Infrastructure.CommonClass.CreateMessage("error", "Please try again.")));
                //var errors = ModelState.Where(x => x.Value.s.SelectMany(key => this.ModelState[key].Errors);
            }
        }
Ejemplo n.º 13
0
        public ActionResult BlockCustomer(Guid id)
        {
            //UserPermissionAction("Account", RoleAction.detail.ToString());
            //CheckPermission();
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("LogOn", "Account"));
            }
            Customer objCustomer = _CustomerService.GetCustomer(id);

            try
            {
                if (objCustomer != null)
                {
                    objCustomer.IsActive = false;
                    _CustomerService.UpdateCustomer(objCustomer);
                    TempData["ShowMessage"] = "success";
                    TempData["MessageBody"] = "Account successfully deactivated.";
                    CommonCls.SendMailOfAccountIsActive(objCustomer.FirstName, objCustomer.EmailId, "deactivated");
                    string UserMessage = "Your account has been deactivated by admin.";
                    string Message     = "{\"flag\":\"" + "Deactivate" + "\",\"UserMessage\":\"" + UserMessage + "\"}";

                    var customerTo = objCustomer;

                    if (customerTo.ApplicationId != null && customerTo.ApplicationId != "")
                    {
                        if (customerTo.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                        {
                            //Send Notification another Andriod
                            CommonCls.SendFCM_Notifications(customerTo.ApplicationId, Message, true);
                        }
                        else
                        {
                            string Msg = UserMessage;

                            CommonCls.TestSendFCM_Notifications(customerTo.ApplicationId, Message, Msg, true);
                        }
                    }
                    return(RedirectToAction("Individuals"));
                }
            }
            catch (Exception ex)
            {
                ErrorLogging.LogError(ex);
                RedirectToAction("Individuals");
            }
            return(RedirectToAction("Individuals"));
        }
Ejemplo n.º 14
0
        //public ActionResult Details(int? UserId)
        //{
        //    var userid = UserId == null ? 0 : UserId;
        //    UserPermissionAction("User", RoleAction.view.ToString());
        //    CheckPermission();
        //    var Customer = _CustomerServices.GetCustomers().Where(c => c.UserId == Convert.ToInt32(userid)).FirstOrDefault();

        //    var model = new CustomerModel();
        //    if (Customer != null)
        //    {
        //        CompanyModel companymodel = new CompanyModel();
        //        var BranchModelList = new List<BranchModel>();
        //        var ServiceItemModelList = new List<ServiceItemModel>();
        //        var ProductModelList = new List<ProductModel>();

        //        Mapper.CreateMap<HomeHelp.Entity.Customer, HomeHelp.Models.CustomerModel>();
        //        model = Mapper.Map<HomeHelp.Entity.Customer, HomeHelp.Models.CustomerModel>(Customer);
        //        model.CompanyID = model.CompanyID == null ? 0 : model.CompanyID;

        //        //Get company detail.
        //        var CompanyDetail = _CompanyService.GetCompany(model.CompanyID);
        //        if (CompanyDetail != null)
        //        {

        //            companymodel.CompanyName = CompanyDetail.CompanyName;
        //            companymodel.CompanyAddress = CompanyDetail.CompanyAddress;
        //            companymodel.HeadOffice = CompanyDetail.HeadOffice;
        //            companymodel.PhoneNo = CompanyDetail.PhoneNo;
        //            companymodel.WebSite = CompanyDetail.WebSite;
        //            companymodel.EmailID = CompanyDetail.EmailID;
        //            companymodel.LogoPath = CompanyDetail.LogoPath;

        //            //Get branches detail.
        //            var Branches = _BranchService.GetBranchs().Where(c => c.CompanyID == CompanyDetail.CompanyID).ToList();
        //            foreach (var Branche in Branches)
        //            {
        //                BranchModel branchmodel = new BranchModel();
        //                branchmodel.BranchName = Branche.BranchName;
        //                branchmodel.CellNumber = Branche.CellNumber;
        //                branchmodel.PhoneNumber = Branche.PhoneNumber;
        //                branchmodel.Location = Branche.Location;
        //                branchmodel.Longitude = Branche.Longitude;
        //                branchmodel.Latitude = Branche.Latitude;
        //                BranchModelList.Add(branchmodel);
        //            }

        //            //Get Customer services detail.
        //            var CustomerServices = _CustomerServicesService.GetCustomerServices().Where(c => c.CustomerId == Customer.CustomerId).ToList();
        //            foreach (var CustomerService in CustomerServices)
        //            {
        //                var ServiceItem = _ServiceItemService.GetServiceItem(Convert.ToInt32(CustomerService.ServiceItemId));
        //                if (ServiceItem != null)
        //                {
        //                    ServiceItemModel ServiceItemModel = new Models.ServiceItemModel();
        //                    ServiceItemModel.ServiceItemName = ServiceItem.ServiceItemName;
        //                    ServiceItemModelList.Add(ServiceItemModel);
        //                }
        //            }

        //            //Get customer intrested product.
        //            var Products = _ProductService.GetProducts().Where(c => c.CustomerId == Customer.CustomerId).ToList();
        //            foreach (var product in Products)
        //            {
        //                ProductModel ProductModel = new ProductModel();
        //                ProductModel.ProductName = product.ProductName;

        //                //Get intrested categories of product.
        //                var Categories = _CategoryService.GetCategories().Where(c => c.ParentId == product.CategoryId).ToList();
        //                var CategoryModelList = new List<CategoryModel>();
        //                foreach (var category in Categories)
        //                {

        //                    CategoryModel CategoryModel = new CategoryModel();
        //                    CategoryModel.Name = category.Name;
        //                    CategoryModelList.Add(CategoryModel);

        //                }
        //                ProductModel.CategoryModelList = CategoryModelList;
        //                ProductModelList.Add(ProductModel);

        //            }
        //        }
        //        //Assign all model list.
        //        model.BranchList = BranchModelList;
        //        model.Company = companymodel;
        //        model.ServiceItemModelList = ServiceItemModelList;
        //        model.ProductModelList = ProductModelList;
        //    }
        //    return View(model);
        //}
        //public ActionResult UpdateUser(int id)
        //{
        //    User user = _UserService.GetUserById(id);
        //    Customer customer = _CustomerServices.GetCustomers().Where(c => c.UserId == user.UserId).FirstOrDefault();

        //    if (customer != null)
        //    {
        //        if (customer.IsActive == true)
        //        {
        //            customer.IsActive = false;
        //        }
        //        else
        //        {
        //            customer.IsActive = true;
        //        }
        //        _CustomerServices.UpdateCustomer(customer);
        //    }

        //    if (user != null)
        //    {
        //        if (user.IsActive == true)
        //        {
        //            user.IsActive = false;
        //        }
        //        else
        //        {
        //            user.IsActive = true;
        //        }
        //        _UserService.UpdateUser(user);
        //    }
        //    return RedirectToAction("Index");
        //}

        public ActionResult Details(Guid Id, string CurrentPageNo)
        {
            UserPermissionAction("User", RoleAction.view.ToString());
            CheckPermission();
            var customer = _CustomerService.GetCustomer(Id);
            var jobs     = new List <JobRequest>();

            if (customer.CustomerType == EnumValue.GetEnumDescription(EnumValue.CustomerType.Customer))
            {
                jobs = _RequestService.GetRequests().Where(j => j.CustomerIdBy == Id).ToList();
            }
            else
            {
                jobs = _RequestService.GetRequests().Where(j => j.CustomerIdTo == Id).ToList();
            }

            var jobList = new List <JObRequestResponseModel>();

            if (jobs.Count() > 0)
            {
                foreach (var job in jobs)
                {
                    Mapper.CreateMap <HomeHelp.Entity.JobRequest, HomeHelp.Models.JObRequestResponseModel>();
                    JObRequestResponseModel JObRequestResponseModel = Mapper.Map <HomeHelp.Entity.JobRequest, HomeHelp.Models.JObRequestResponseModel>(job);
                    JObRequestResponseModel.CustomerToName  = _CustomerService.GetCustomer(JObRequestResponseModel.CustomerIdTo).FirstName + " " + _CustomerService.GetCustomer(JObRequestResponseModel.CustomerIdBy).LastName;
                    JObRequestResponseModel.CustomerToImage = _CustomerService.GetCustomer(JObRequestResponseModel.CustomerIdTo).PhotoPath;
                    JObRequestResponseModel.CategoryName    = _CategoryService.GetCategory(Convert.ToInt32(_CustomerService.GetCustomer(JObRequestResponseModel.CustomerIdTo).CategoryId)).Name;
                    jobList.Add(JObRequestResponseModel);
                }
                return(View(jobList));
            }
            else
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = " Location has no details.";
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult DisapproveEvents(int?Id, string ReasonToDisapprove)
        {
            try
            {
                if (Id != 0)
                {
                    var location = _LocationService.GetLocations().Where(l => l.LocationId == Id).FirstOrDefault();

                    if (location != null)
                    {
                        location.IsApproved = false;
                        location.Status     = EnumValue.GetEnumDescription(EnumValue.LocationStatus.Disapproved);
                        _LocationService.UpdateLocation(location);
                    }
                    var customer = _CustomerService.GetCustomers().Where(l => l.CustomerId == location.CustomerId).FirstOrDefault();
                    SendMailToUser(customer.FirstName, location.Title, location.EmailId, ReasonToDisapprove);
                    TempData["ShowMessage"] = "success";
                    TempData["MessageBody"] = " Location disapproved  successfully.";
                    return(Json(new { success = true, responseText = "Location disapproved  successfully." }, JsonRequestBehavior.AllowGet));
                }



                else
                {
                    TempData["ShowMessage"] = "error";
                    TempData["MessageBody"] = " Location not found. ";
                    return(Json(new { success = false, responseText = "error." }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Json(new { success = false, responseText = "error." }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 16
0
        public ActionResult GetPropertyTypes(string Type)
        {
            if (Type == "")
            {
                Type = Request.QueryString["Type"] == null ? "Residential" : Request.QueryString["Type"].ToString();
            }
            var PropertyType = new List <PropertyType>();

            if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Residential))
            {
                PropertyType = _ResidentialService.GetPropertyTypes();
            }
            else if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Commercial))
            {
                PropertyType = _CommercialService.GetPropertyTypes_Comm();
            }
            else if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Condo))
            {
                PropertyType = _CondoService.GetPropertyTypes_Condo();
            }
            else
            {
                PropertyType = _ResidentialService.GetPropertyTypes();
            }
            List <SelectListItem> PropertyTypes = new List <SelectListItem>();

            foreach (var item in PropertyType)
            {
                PropertyTypes.Add(new SelectListItem
                {
                    Value = item.typeown1out,
                    Text  = item.typeown1out
                });
            }

            return(Json(PropertyTypes, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 17
0
        public void Execute(IJobExecutionContext context)
        {
            JobDataMap dataMap   = context.JobDetail.JobDataMap;
            string     userId    = dataMap.GetString("UserId");
            string     emailType = dataMap.GetString("EmailType");
            var        user      = _userService.GetUser(userId);

            if (user != null)
            {
                //Start : Insert Email Verification
                EmailVerification emailverification = new EmailVerification();
                emailverification.UserId          = user.UserId;
                emailverification.EmailType       = emailType;
                emailverification.ActiveForMinute = ConstantModel.ProjectSettings.EmailExpireLimit; //Valid upto 24-Hours
                emailverification.IsActive        = true;
                emailverification.IsOperationDone = false;
                var emailVerificationResult = _emailVerificationService.InsertEmailVerification(emailverification);
                //End : Insert Email Verification

                //Start : Sending welcome mail after registeration or Reverify account email
                EmailManager emailManager = new EmailManager();
                EMailEntity  emailEntity  = new EMailEntity();
                emailEntity.ToMail    = user.EmailId;
                emailEntity.RequestId = emailVerificationResult.EmailVerificationId.ToString(); //Here RequestId is EmailVerificationId
                emailEntity.FirstName = user.FirstName;
                if (emailType == EnumValue.GetEnumDescription(EnumValue.EmailType.WelcomeEmail))
                {
                    emailManager.SendMailOfWelcome(emailEntity);
                }
                else if (emailType == EnumValue.GetEnumDescription(EnumValue.EmailType.ReverifyAccount))
                {
                    emailManager.SendMailForReverifyAccount(emailEntity);
                }
                //End : Sending welcome mail after registeration or Reverify account email
            }
        }
        // GET: /Account/ForgotPasswordMail
        public JsonResult ForgotPasswordMail(RegisterModel registerModel)
        {
            int result = -1;

            try
            {
                var userInfo = base._userService.GetUserByName(registerModel.Email);
                if (userInfo != null)
                {
                    EmailVerification emailverification = new EmailVerification();
                    emailverification.UserId          = userInfo.UserId;
                    emailverification.EmailType       = EnumValue.GetEnumDescription(EnumValue.EmailType.ResetPassword);
                    emailverification.ActiveForMinute = ConstantModel.ProjectSettings.EmailExpireLimit; //Valid upto 24-Hours
                    emailverification.IsActive        = true;
                    emailverification.IsOperationDone = false;
                    var emailVerificationResult = _emailVerificationService.InsertEmailVerification(emailverification);

                    EmailManager emailManager = new EmailManager();
                    EMailEntity  emailEntity  = new EMailEntity();
                    emailEntity.ToMail    = userInfo.EmailId;
                    emailEntity.RequestId = emailVerificationResult.EmailVerificationId.ToString();
                    emailEntity.FirstName = userInfo.FirstName;
                    result = emailManager.SendMailForResetPassword(emailEntity);

                    return(Json(Infrastructure.CommonClass.CreateMessage("success", result), JsonRequestBehavior.AllowGet));
                }
                return(Json(Infrastructure.CommonClass.CreateMessage("error", "This email id does not exist. Please try again."), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                string   ErrorMsg = ex.Message.ToString();
                ErrorLog errorlog = new ErrorLog();
                errorlog.LogError(ex);
                return(Json(Infrastructure.CommonClass.CreateMessage("error", "Something went wrong.Please try later."), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Index(int?key)
        {
            //UserPermissionAction("Category", RoleAction.view.ToString(), operation, ShowMessage, MessageBody);
            //CheckPermission();
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("LogOn", "Account"));
            }
            if (key == 1)
            {
                Session["CurrentPageNumber"] = null;
            }
            if (Session["CurrentPageNumber"] == null)
            {
                ViewBag.currentPageNumber = 0;
            }
            else
            {
                ViewBag.currentPageNumber = Convert.ToInt32(Session["CurrentPageNumber"]);
            }
            List <AgencyIndividualModel> AgencyIndividualModels = new List <AgencyIndividualModel>();
            int id = Convert.ToInt32(Session["UserId"].ToString());

            if (id > 0)
            {
                var Users = _AgencyIndividualService.GetAgencyIndividualByUserId(id);

                var myIndividuals = _AgencyIndividualService.GetAgencyIndividualByParentId(Users.AgencyIndividualId);
                Mapper.CreateMap <AgencyIndividual, AgencyIndividualModel>();
                foreach (var User in myIndividuals)
                {
                    var cc            = _CustomerService.GetCustomerByUserId(User.UserId);
                    var inProgressJob = _RequestService.GetProgressRequest(cc.CustomerId, EnumValue.GetEnumDescription(EnumValue.JobStatus.InProgress));
                    var _User         = Mapper.Map <AgencyIndividual, AgencyIndividualModel>(User);
                    if (inProgressJob.Count > 0)
                    {
                        foreach (var item in inProgressJob)
                        {
                            if (cc.CustomerId == item.CustomerIdTo)
                            {
                                _User.inProgress = true;
                                //Mapper.CreateMap<JobRequest, RequestModel>();
                                //var _requestData = Mapper.Map<JobRequest, RequestModel>(item);
                                _User.jobRequestId = item.CustomerIdTo;
                            }
                            else
                            {
                                _User.inProgress = false;
                            }
                        }
                    }
                    AgencyIndividualModels.Add(_User);
                }
                return(View(AgencyIndividualModels));
            }
            else
            {
                return(RedirectToAction("LogOn", "Account"));
            }
        }
        public ActionResult AssignRequest(Guid assignedId, int jobRequestId)
        {
            string UserMessage = "";
            string Flag        = "";

            if (Session["UserId"] == null)
            {
                return(RedirectToAction("LogOn", "Account"));
            }
            if (assignedId == null || jobRequestId == 0)
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                RequestModel requestModel = new RequestModel();
                Mapper.CreateMap <JobRequest, RequestModel>();
                var jobRequestDetail = _RequestService.GetRequest(jobRequestId);
                var customerToData   = _AgencyIndividualService.GetAgencyIndividual(assignedId);
                var data             = _CustomerService.GetCustomerByUserId(customerToData.UserId);
                int id = Convert.ToInt32(Session["UserId"].ToString());
                if (id > 0)
                {
                    var assignedBy = _AgencyIndividualService.GetAgencyIndividualByUserId(id);
                    UserMessage = "You have new job request by " + assignedBy.FullName;
                    Flag        = "NewRequest";
                    Notification notification = new Notification();
                    notification.CustomerIdBy = assignedBy.AgencyIndividualId;

                    //notification.CustomerIdTo = data.CustomerId;
                    notification.CustomerIdTo = data.CustomerId;

                    notification.SourceId    = jobRequestDetail.JobRequestId;
                    notification.UserMessage = UserMessage;
                    //notification.NotificationType = Convert.ToString(EnumValue.NotificationType.Request);
                    notification.Flag               = Flag;
                    notification.DeviceType         = data.DeviceType;
                    notification.NotificationStatus = EnumValue.GetEnumDescription(EnumValue.RequestStatus.New);
                    _NotificationService.InsertNotification(notification);

                    string Message = "{\"flag\":\"" + Flag + "\",\"JobRequestId\":\"" + jobRequestDetail.JobRequestId + "\",\"UserMessage\":\"" + UserMessage + "\"}";

                    if (data.ApplicationId != null && data.ApplicationId != "")
                    {
                        if (data.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                        {
                            //Send Notification another Andriod
                            CommonCls.SendFCM_Notifications(data.ApplicationId, Message, true);
                        }
                        else
                        {
                            string Msg = UserMessage;

                            CommonCls.TestSendFCM_Notifications(data.ApplicationId, Message, Msg, true);
                        }
                    }
                }
                else
                {
                    return(RedirectToAction("LogOn", "Account"));
                }
                jobRequestDetail.CustomerIdTo = data.CustomerId;
                var assignedJob = _AgencyJobService.GetAgencyJobByJobRequest(jobRequestDetail.JobRequestId);
                assignedJob.AgencyIndividualId = data.CustomerId;
                if (jobRequestDetail.JobStatus == EnumValue.GetEnumDescription(EnumValue.RequestStatus.Declined))
                {
                    jobRequestDetail.RequestStatus = EnumValue.GetEnumDescription(EnumValue.RequestStatus.New);
                    jobRequestDetail.JobStatus     = EnumValue.GetEnumDescription(EnumValue.JobStatus.Pending);
                    assignedJob.Status             = EnumValue.GetEnumDescription(EnumValue.JobStatus.Pending);
                }

                _RequestService.UpdateRequest(jobRequestDetail);
                _AgencyJobService.UpdateAgencyJob(assignedJob);


                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Edit([Bind(Include = "CustomerId,TrebId,WebsiteUrl,ApplicationID,Password,CompanyID,UserId,PhotoPath,FirstName,LastName,MiddleName,EmailID,DOB,MobileNo,CountryID,StateID,CityID,ZipCode,Latitude,Longitude,CreatedOn,LastUpdatedOn,MobileVerifyCode,EmailVerifyCode,IsMobileVerified,IsEmailVerified,IsActive,RecoNumber,RecoExpireDate")] CustomerModel Customermodel, HttpPostedFileBase file)
        {
            UserPermissionAction("property", RoleAction.view.ToString());
            CheckPermission();
            TempData["ShowMessage"] = "";
            TempData["MessageBody"] = "";
            try
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = "Please fill the required field with valid data";
                if (ModelState.IsValid)
                {
                    var CustomerFound = _CustomerService.GetCustomers().Where(c => ((c.EmailId.Trim() == Customermodel.EmailID.Trim() || c.MobileNo.Trim() == Customermodel.MobileNo.Trim()) && c.CustomerId != Customermodel.CustomerId)).FirstOrDefault();
                    if (CustomerFound == null)
                    {
                        var PhotoPath = "";

                        var CustomerUpdate = _CustomerService.GetCustomer(Customermodel.CustomerId);//.Where(c => c.CustomerId == Customermodel.CustomerId).FirstOrDefault();
                        if (CustomerUpdate != null)
                        {
                            PhotoPath = CustomerUpdate.PhotoPath;
                            if (file != null)
                            {
                                if (CustomerUpdate.PhotoPath != "")
                                {   //Delete Old Image
                                    string pathDel = Server.MapPath("~/CustomerPhoto");

                                    FileInfo objfile = new FileInfo(pathDel);
                                    if (objfile.Exists) //check file exsit or not
                                    {
                                        objfile.Delete();
                                    }
                                    //End :Delete Old Image
                                }

                                //Save the photo in Folder
                                var    fileExt  = Path.GetExtension(file.FileName);
                                string fileName = Guid.NewGuid() + fileExt;
                                var    subPath  = Server.MapPath("~/CustomerPhoto");

                                //Check SubPath Exist or Not
                                if (!Directory.Exists(subPath))
                                {
                                    Directory.CreateDirectory(subPath);
                                }
                                //End : Check SubPath Exist or Not

                                var path = Path.Combine(subPath, fileName);
                                file.SaveAs(path);

                                PhotoPath = CommonCls.GetURL() + "/CustomerPhoto/" + fileName;
                            }


                            CommonClass CommonClass = new CommonClass();
                            string      QStr        = "";
                            DataTable   dt          = new DataTable();
                            QStr  = "update Customer set PhotoPath='" + PhotoPath + "' ,MobileNo='" + Customermodel.MobileNo + "' ,Address='" + Customermodel.Address + "' ,FirstName='" + Customermodel.FirstName + "' ";
                            QStr += " ,LastName='" + Customermodel.LastName + "',MiddleName='" + Customermodel.MiddleName + "' ,EmailId='" + Customermodel.EmailID + "' ,CityID='" + Convert.ToInt32(Customermodel.CityID) + "' ,StateID='" + Convert.ToInt32(Customermodel.StateID) + "' , ";
                            QStr += "IsActive='" + Convert.ToBoolean(Customermodel.IsActive) + "' ,WebsiteUrl='" + Customermodel.WebsiteUrl + "' ,UpdateStatus='" + true + "' Where CustomerId='" + Convert.ToInt32(Customermodel.CustomerId) + "'  ";
                            CommonClass.ExecuteNonQuery(QStr);
                            // dt = CommonClass.GetDataSet(QStr).Tables[0];
                            CustomerUpdate.LastUpdatedOn = DateTime.Now;
                            _CustomerService.UpdateCustomer(CustomerUpdate);
                            if (Customermodel.IsActive == false)
                            {
                                string Flag = "14";
                                var    NotificationStatus = false;
                                string Message            = "Your account is deactivated";
                                string JsonMessage        = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\"}";
                                //Save Notification
                                Notification Notification = new Notification();
                                Notification.NotificationSendBy = 1;
                                Notification.NotificationSendTo = Convert.ToInt32(CustomerUpdate.CustomerId);
                                Notification.IsRead             = false;
                                Notification.Flag           = Convert.ToInt32(Flag);
                                Notification.RequestMessage = Message;
                                _Notification.InsertNotification(Notification);
                                if (CustomerUpdate.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                                {
                                    CommonCls.SendGCM_Notifications(CustomerUpdate.ApplicationId, JsonMessage, true);
                                }
                                else
                                {
                                    //Dictionary<string, object> Dictionary = new Dictionary<string, object>();
                                    //Dictionary.Add("Flag", Flag);
                                    //Dictionary.Add("Message", Message);
                                    //NotificationStatus = PushNotificatinAlert.SendPushNotification(CustomerUpdate.ApplicationId, Message, Flag.ToString(), JsonMessage, Dictionary, 1);
                                    int count = _Notification.GetNotifications().Where(c => c.NotificationSendTo == Convert.ToInt32(CustomerUpdate.CustomerId) && c.IsRead == false).ToList().Count();

                                    CommonCls.TestSendFCM_Notifications(CustomerUpdate.ApplicationId, JsonMessage, Message, count, true);
                                }
                            }
                            string FirstName = CustomerUpdate.FirstName + " " + CustomerUpdate.MiddleName + " " + CustomerUpdate.LastName;
                            if (CustomerUpdate.IsUpdated == true)
                            {
                                SendMailToUpdatedUser(FirstName, CustomerUpdate.EmailId, CustomerUpdate.TrebId);
                            }
                            else
                            {
                                SendMailToUser(FirstName, CustomerUpdate.EmailId, CustomerUpdate.TrebId);
                            }



                            TempData["ShowMessage"] = "success";
                            TempData["MessageBody"] = CustomerUpdate.FirstName + " is update successfully.";
                        }
                        else
                        {
                            TempData["ShowMessage"] = "error";
                            TempData["MessageBody"] = "Customer not found.";
                        }
                        return(RedirectToAction("customerlist", "Property"));
                    }
                    else
                    {
                        TempData["ShowMessage"] = "error";

                        if (CustomerFound.EmailId.Trim() == Customermodel.EmailID.Trim())
                        {
                            TempData["MessageBody"] = Customermodel.EmailID + " is already exists.";
                        }
                        if (CustomerFound.TrebId.Trim() == Customermodel.TrebId.Trim())
                        {
                            TempData["MessageBody"] = Customermodel.TrebId + " is already exists.";
                        }
                        if (CustomerFound.MobileNo.Trim() == Customermodel.MobileNo.Trim())
                        {
                            TempData["MessageBody"] = "This" + " " + Customermodel.MobileNo + " is already exists.";
                        }
                        else
                        {
                            TempData["MessageBody"] = "Please fill the required field with valid data";
                        }
                    }
                }
            }


            catch (RetryLimitExceededException)
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on " + Customermodel.FirstName + " client";
            }
            var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);

            //ViewBag.CityID = new SelectList(_CityService.GetCities(), "CityID", "CityName", Carriermodel.CityID);
            // ViewBag.CompanyID = new SelectList(_CompanyService.GetCompanies(), "CompanyID", "CompanyName", Customermodel.CompanyID);
            //ViewBag.CountryID = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Carriermodel.CountryID);
            //ViewBag.StateID = new SelectList(_StateService.GetStates(), "StateID", "StateName", Carriermodel.StateID);
            ViewBag.UserId      = new SelectList(_UserService.GetUsers(), "UserId", "FirstName", Customermodel.UserId);
            ViewBag.CityID      = (Customermodel.CityID <= 0 ? "" : Customermodel.CityID.ToString());
            ViewBag.StateID     = (Customermodel.StateID <= 0 ? "" : Customermodel.StateID.ToString());
            ViewBag.Countrylist = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Customermodel.CountryID);
            ViewBag.Statelist   = new SelectList(_StateService.GetStates(), "StateID", "StateName", Customermodel.StateID);
            ViewBag.Citylist    = new SelectList(_CityService.GetCities(), "CityID", "CityName", Customermodel.CityID);


            return(View(Customermodel));
        }
Ejemplo n.º 22
0
        public ActionResult Index(string Type = "Residential", string MLS = "W4194008")
        {
            var result = new PropertyModel();

            if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Residential))
            {
                result = _ResidentialService.GetSingleProperty(MLS);
            }
            else if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Commercial))
            {
                result = _CommercialService.GetSingleProperty(MLS);
            }
            else
            {
                result = _CondoService.GetSingleProperty(MLS);
            }
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <PropertyModel, PropertyModell>();
            });
            IMapper mapper = config.CreateMapper();
            var     dest   = mapper.Map <PropertyModel, PropertyModell>(result);

            if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Residential))
            {
                dest.images = _ResidentialService.GetImageByMLSID(MLS);
            }
            else if (Type == EnumValue.GetEnumDescription(EnumValue.PropertyType.Commercial))
            {
                dest.images = _CommercialService.GetImageByMLSID(MLS);
            }
            else
            {
                dest.images = _CondoService.GetImageByMLSID(MLS);
            }
            int NoOfRoom           = Convert.ToInt32(result.Rooms);
            List <RoomLevels> list = new List <RoomLevels>();

            int i = 0;

            if (NoOfRoom != i)
            {
                RoomLevels obj = new RoomLevels();
                obj.Level    = result.Level1;
                obj.Room     = result.Room1;
                obj.RoomDesc = result.Room1Desc1 + result.Room1Desc2;
                obj.RoomDim  = result.Room1Length + "x" + result.Room1Width;
                list.Add(obj);
                i = i + 1;
            }

            if (NoOfRoom != i)
            {
                RoomLevels obj1 = new RoomLevels();
                obj1.Level    = result.Level2;
                obj1.Room     = result.Room2;
                obj1.RoomDesc = result.Room2Desc1 + result.Room2Desc2;
                obj1.RoomDim  = result.Room2Length + "x" + result.Room2Width;
                list.Add(obj1);
                i = i + 1;
            }

            if (NoOfRoom != i)
            {
                RoomLevels obj2 = new RoomLevels();
                obj2.Level    = result.Level3;
                obj2.Room     = result.Room3;
                obj2.RoomDesc = result.Room3Desc1 + result.Room3Desc2;
                obj2.RoomDim  = result.Room3Length + "x" + result.Room3Width;
                list.Add(obj2);
                i = i + 1;
            }

            if (NoOfRoom != i)
            {
                RoomLevels obj3 = new RoomLevels();
                obj3.Level    = result.Level4;
                obj3.Room     = result.Room4;
                obj3.RoomDesc = result.Room4Desc1 + result.Room4Desc2;
                obj3.RoomDim  = result.Room4Length + "x" + result.Room4Width;
                list.Add(obj3);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj4 = new RoomLevels();
                obj4.Level    = result.Level5;
                obj4.Room     = result.Room5;
                obj4.RoomDesc = result.Room5Desc1 + result.Room5Desc2;
                obj4.RoomDim  = result.Room5Length + "x" + result.Room5Width;
                list.Add(obj4);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj5 = new RoomLevels();
                obj5.Level    = result.Level6;
                obj5.Room     = result.Room6;
                obj5.RoomDesc = result.Room6Desc1 + result.Room6Desc2;
                obj5.RoomDim  = result.Room6Length + "x" + result.Room6Width;
                list.Add(obj5);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj6 = new RoomLevels();
                obj6.Level    = result.Level7;
                obj6.Room     = result.Room7;
                obj6.RoomDesc = result.Room7Desc1 + result.Room7Desc2;
                obj6.RoomDim  = result.Room7Length + "x" + result.Room7Width;
                list.Add(obj6);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj7 = new RoomLevels();
                obj7.Level    = result.Level8;
                obj7.Room     = result.Room8;
                obj7.RoomDesc = result.Room8Desc1 + result.Room8Desc2;
                obj7.RoomDim  = result.Room8Length + "x" + result.Room8Width;
                list.Add(obj7);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj8 = new RoomLevels();
                obj8.Level    = result.Level9;
                obj8.Room     = result.Room9;
                obj8.RoomDesc = result.Room9Desc1 + result.Room9Desc2;
                obj8.RoomDim  = result.Room9Length + "m x " + result.Room9Width + "m";
                list.Add(obj8);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj9 = new RoomLevels();
                obj9.Level    = result.Level10;
                obj9.Room     = result.Room10;
                obj9.RoomDesc = result.Room10Desc1 + result.Room10Desc2;
                obj9.RoomDim  = result.Room10Length + "m x " + result.Room10Width + "m";
                list.Add(obj9);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj10 = new RoomLevels();
                obj10.Level    = result.Level11;
                obj10.Room     = result.Room11;
                obj10.RoomDesc = result.Room11Desc1 + result.Room11Desc2;
                obj10.RoomDim  = result.Room11Length + "m x " + result.Room11Width + "m";
                list.Add(obj10);
                i = i + 1;
            }
            if (NoOfRoom != i)
            {
                RoomLevels obj11 = new RoomLevels();
                obj11.Level    = result.Level12;
                obj11.Room     = result.Room12;
                obj11.RoomDesc = result.Room12Desc1 + result.Room12Desc2;
                obj11.RoomDim  = result.Room12Length + "m x " + result.Room12Width + "m";
                list.Add(obj11);
                i = i + 1;
            }

            dest.roomlevels = list.GroupBy(c => c.Level)
                              .Select(group =>
                                      new RoomLevelList
            {
                Level     = group.Key,
                roomlevel = group.ToList()
            })
                              .ToList();
            return(View(dest));
        }
        public HttpResponseMessage SaveChat([FromBody] ChatModel chatModel)
        {
            string ChatID = "-1";

            try
            {
                if (chatModel.CustomerIdBy == new Guid())
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "CustomerId By is blank."), Configuration.Formatters.JsonFormatter));
                }
                if (chatModel.CustomerIdTo == new Guid())
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "CustomerId To is blank."), Configuration.Formatters.JsonFormatter));
                }
                var customerTo = _CustomerService.GetCustomer(chatModel.CustomerIdTo);
                if (customerTo == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer To not found."), Configuration.Formatters.JsonFormatter));
                }
                var customerBy = _CustomerService.GetCustomer(chatModel.CustomerIdBy);
                if (customerBy == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer By not found."), Configuration.Formatters.JsonFormatter));
                }
                if (chatModel.ChatContent != null && chatModel.ChatContent != "")
                {
                    List <Guid?> ListCustomerIDs = new List <Guid?>();
                    ListCustomerIDs.Add(chatModel.CustomerIdBy);
                    ListCustomerIDs.Add(chatModel.CustomerIdTo);


                    var isFriend = _RequestService.GetRequests().Where(x => ListCustomerIDs.Contains(x.CustomerIdBy) && ListCustomerIDs.Contains(x.CustomerIdTo)).FirstOrDefault();
                    if (isFriend != null)
                    {
                        Mapper.CreateMap <HomeHelp.Models.ChatModel, HomeHelp.Entity.Chat>();
                        HomeHelp.Entity.Chat chat = Mapper.Map <HomeHelp.Models.ChatModel, HomeHelp.Entity.Chat>(chatModel);
                        if (chatModel.ChatId <= 0)
                        {
                            TimeZoneInfo tz = TimeZoneInfo.Local;
                            chat.DateTimeCreated = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now, tz);
                            _ChatService.Insert(chat); //Save Operation
                            ChatID = chat.ChatId.ToString();
                        }

                        // Code For GCM & Iphone
                        //var Customer = _CustomerService.GetCustomer(Convert.ToInt32(chatModel.CustomerIdTo));
                        //if (Customer != null)
                        //{
                        //    var Chats = _ChatService.GetAll().ToList();
                        //    var Results = (from m in Chats
                        //                   where m.CustomerIdTo == chatModel.CustomerIdTo && m.IsRead == false
                        //                   group m by new { m.CustomerIdTo } into g
                        //                   select new
                        //                   {
                        //                       CustomerIdBy = g.Key.CustomerIdTo,
                        //                       ChatContent = (from c in Chats
                        //                                      where c.CustomerIdTo == chatModel.CustomerIdTo && c.IsRead == false
                        //                                      orderby c.DateTimeCreated descending
                        //                                      select c.ChatContent).FirstOrDefault(),
                        //                       Count = g.Count()
                        //                   }).ToList();

                        //    var models = new List<ChatModel>();

                        //    var UserMessage = "";
                        //    bool NotificationStatus = true;
                        //    if (Results.Count() >= 0)
                        //    {
                        //        int MessageCount = Convert.ToInt32(Results.Sum(x => x.Count).ToString()) + 1;
                        string UserMessage = "You have new message.";

                        string NotificationType = "chat";
                        string Flag             = "NewChatMessage";

                        //Save notification in Table
                        Notification Notification = new Notification();
                        Notification.NotificationId = 0; //New Case
                        //Notification.ClientId = _Event.ClientID; Save it as NULL
                        Notification.CustomerIdBy = customerBy.CustomerId;
                        Notification.CustomerIdTo = customerTo.CustomerId;
                        //Notification.EventID = _Event.EventID; Save it as NULL
                        Notification.UserMessage      = UserMessage;
                        Notification.NotificationType = NotificationType;
                        Notification.Flag             = Flag;
                        Notification.DeviceType       = customerBy.DeviceType;
                        _NotificationService.InsertNotification(Notification);
                        //        //End : Save notification in Table

                        // string Message = "{\"flag\":\"" + Flag + "\",\"message\":\"" + UserMessage + "\",\"ChatContent\":\"" + chatModel.ChatContent + "\"}";


                        string Message = "{ \"ChatId\": \"" + ChatID + "\",      \"CustomerIdBy\": \"" + customerBy.CustomerId + "\", \"CustomerIdTo\": \"" + customerTo.CustomerId + "\",      \"ChatContent\": \"" + chatModel.ChatContent
                                         + "\",      \"flag\": \"" + Flag + "\",      \"IsRead\": \"" + chat.IsRead + "\",     \"IsDeletedCustomerBy\":\"" + chat.IsDeletedCustomerBy
                                         + "\",      \"IsDeletedCustomerTo\": \"" + chat.IsDeletedCustomerTo + "\",     \"DateTimeCreated\": \""
                                         + chat.DateTimeCreated + "\",      \"CustomersBy\": { \"CustomerId\": \"" + customerBy.CustomerId
                                         + "\",       \"FirstName\": \"" + customerBy.FirstName + "\",        \"LastName\": \"" + customerBy.LastName
                                         + "\",       \"PhotoPath\": \"" + customerBy.PhotoPath + "\"      }, \"CustomersTo\": { \"CustomerId\": \"" + customerTo.CustomerId + "\",       \"FirstName\": \"" + customerTo.FirstName + "\",      \"LastName\": \"" + customerTo.LastName + "\",       \"PhotoPath\": \"" + customerTo.PhotoPath + "\"     }     }";


                        if (customerTo.ApplicationId != null && customerTo.ApplicationId != "")
                        {
                            if (customerTo.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                            {
                                //Send Notification another Andriod
                                CommonCls.SendFCM_Notifications(customerTo.ApplicationId, Message, true);
                            }
                            else
                            {
                                string Msg = customerTo.FirstName + " " + customerTo.LastName + " : " + chat.ChatContent;

                                CommonCls.TestSendFCM_Notifications(customerTo.ApplicationId, Message, Msg, true);
                                //CommonCls.TestSendFCM_Notifications(customerTo.ApplicationId, Message, true);
                            }
                        }
                        Mapper.CreateMap <HomeHelp.Entity.Chat, HomeHelp.Models.ChatResponseModel>();
                        HomeHelp.Models.ChatResponseModel ChatModel = Mapper.Map <HomeHelp.Entity.Chat, HomeHelp.Models.ChatResponseModel>(chat);
                        string sqlFormattedDate = chat.DateTimeCreated.HasValue ? chat.DateTimeCreated.Value.ToString("yyyy-MM-dd HH:mm:ss.fff") : "";

                        ChatModel.DateTimeCreated = sqlFormattedDate;

                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", ChatModel), Configuration.Formatters.JsonFormatter));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "they are not associated."), Configuration.Formatters.JsonFormatter));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Chat content is blank."), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Please try later"), Configuration.Formatters.JsonFormatter));
            }
        }
        public async Task <HttpResponseMessage> UploadCustomerProfile()
        {
            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }
            string root = HttpContext.Current.Server.MapPath("~/CustomerPhoto/temp");

            CustomMultipartFormDataStreamProvider1 provider = new CustomMultipartFormDataStreamProvider1(root);

            try
            {
                StringBuilder sb = new StringBuilder();     // Holds the response body

                Type          type = typeof(CustomerModel); // Get type pointer
                CustomerModel locationImagesModel = new CustomerModel();

                // Read the form data and return an async task.
                CustomMultipartFormDataStreamProvider1 x = await Request.Content.ReadAsMultipartAsync(provider);

                int    CustomerId  = 0;
                string Bio         = "";
                string Privacy     = "";
                int    Age         = 0;
                string Gender      = "";
                string Music       = "";
                string Photography = "";
                string Camping     = "";
                string Hiking      = "";
                // This illustrates how to get the form data.
                foreach (var key in provider.FormData.AllKeys)
                {
                    if (key == "CustomerId")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            CustomerId = Convert.ToInt32(propertyValue);
                            if (CustomerId == 0)
                            {
                                return(ErrorMessage("error", "Customer Id is blank."));
                            }
                        }
                    }
                    if (key == "Age")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            Age = Convert.ToInt32(propertyValue);
                            if (Age == 0)
                            {
                                return(ErrorMessage("error", "Age is blank."));
                            }
                        }
                    }
                    if (key == "Bio")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            Bio = propertyValue;
                            if (Bio == "" || Bio == null)
                            {
                                return(ErrorMessage("error", "Bio is blank."));
                            }
                        }
                    }
                    if (key == "Privacy")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            Privacy = propertyValue;
                            if (Privacy != EnumValue.GetEnumDescription(EnumValue.Privacy.Public) && Privacy != EnumValue.GetEnumDescription(EnumValue.Privacy.Private))
                            {
                                return(ErrorMessage("error", "Privacy is wrong."));
                            }
                            if (Privacy == "" || Privacy == null)
                            {
                                return(ErrorMessage("error", "Privacy is blank."));
                            }
                        }
                    }
                    if (key == "Gender")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            Gender = propertyValue;
                            if (Gender != EnumValue.GetEnumDescription(EnumValue.Gender.Female) && Gender != EnumValue.GetEnumDescription(EnumValue.Gender.Male))
                            {
                                return(ErrorMessage("error", "Gender is wrong."));
                            }
                            if (Gender == "" || Gender == null)
                            {
                                return(ErrorMessage("error", "Gender is blank."));
                            }
                        }
                    }
                    if (key == "Music")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            Music = propertyValue;
                            if (Music == "" || Music == null)
                            {
                                return(ErrorMessage("error", "Music is blank."));
                            }
                        }
                    }
                    if (key == "Photography")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (Photography != null)
                        {
                            Photography = propertyValue;
                            if (Photography == "" || Photography == null)
                            {
                                return(ErrorMessage("error", "Photography is blank."));
                            }
                        }
                    }
                    if (key == "Camping")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            Camping = propertyValue;
                            if (Camping == "" || Camping == null)
                            {
                                return(ErrorMessage("error", "Camping is blank."));
                            }
                        }
                    }

                    if (key == "Hiking")
                    {
                        string propertyValue = provider.FormData.GetValues(key).FirstOrDefault();
                        if (propertyValue != null)
                        {
                            Hiking = propertyValue;
                            if (Hiking == "" || Hiking == null)
                            {
                                return(ErrorMessage("error", "Hiking is blank."));
                            }
                        }
                    }

                    if (CustomerId != 0 && Bio != "" && Privacy != "" && Age != 0 && Gender != "" && Music != "" && Photography != "" && Camping != "" && Hiking != "")
                    {
                        break;
                    }
                }

                //Delete all already exist files
                HomeHelp.Entity.Customer Customer = _CustomerService.GetCustomers().Where(c => c.CustomerId == CustomerId && c.IsActive == true).FirstOrDefault();
                if (Customer != null)
                {
                    if (Customer.PhotoPath != "" && Customer.PhotoPath != null)
                    {
                        DeleteImage(Customer.BackgroundImage);
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "No user found."), Configuration.Formatters.JsonFormatter));
                }

                // Process the list of files found in the directory.
                string[] fileEntries = Directory.GetFiles(root);
                foreach (string fileName in fileEntries)
                {
                    var fileFound = provider.FileData.Where(c => c.Headers.ContentDisposition.FileName.Replace("\"", string.Empty) == Path.GetFileName(fileName)).FirstOrDefault();
                    if (fileFound != null)
                    {
                        //string NewFileName = Guid.NewGuid() + "_Event" + EventId.ToString() + Path.GetExtension(fileName);
                        string NewFileName = Guid.NewGuid() + Path.GetExtension(fileName);

                        string NewRoot = HttpContext.Current.Server.MapPath("~/CustomerPhoto") + "\\" + NewFileName;

                        System.IO.File.Move(fileName, NewRoot);

                        string URL = CommonCls.GetURL() + "/CustomerPhoto/" + NewFileName;

                        Customer.PhotoPath = URL;

                        sb.Append(URL);
                    }
                }
                Customer.Bio     = Bio;
                Customer.Privacy = Privacy;
                Customer.Age     = Age;
                Customer.Gender  = Gender;
                _CustomerService.UpdateCustomer(Customer);
                HobbiesAndInterests hobbies = _HobbiesAndInterestsService.GetHobbiesAndInterestss().Where(c => c.CustomerId == CustomerId).FirstOrDefault();
                if (hobbies != null)
                {
                    hobbies.Music       = Convert.ToInt32(Music);
                    hobbies.Hiking      = Convert.ToInt32(Hiking);
                    hobbies.Camping     = Convert.ToInt32(Camping);
                    hobbies.Photography = Convert.ToInt32(Photography);
                    hobbies.CustomerId  = CustomerId;
                    _HobbiesAndInterestsService.UpdateHobbiesAndInterests(hobbies);
                }
                else
                {
                    HobbiesAndInterests objHobbies = new HobbiesAndInterests();
                    objHobbies.Music       = Convert.ToInt32(Music);
                    objHobbies.Hiking      = Convert.ToInt32(Hiking);
                    objHobbies.Camping     = Convert.ToInt32(Camping);
                    objHobbies.Photography = Convert.ToInt32(Photography);
                    objHobbies.CustomerId  = CustomerId;
                    _HobbiesAndInterestsService.InsertHobbiesAndInterests(objHobbies);
                }
                Mapper.CreateMap <Customer, UserCustomerModel>();
                UserCustomerModel userCustomerModel = Mapper.Map <Customer, UserCustomerModel>(Customer);
                userCustomerModel.Music       = Music;
                userCustomerModel.Hiking      = Hiking;
                userCustomerModel.Camping     = Camping;
                userCustomerModel.Photography = Photography;
                return(ErrorMessage("success", userCustomerModel));
            }
            catch (System.Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
        public ActionResult Create(EventModel EventModel, HttpPostedFileBase file)
        {
            UserPermissionAction("event", RoleAction.view.ToString());
            CheckPermission();
            TempData["ShowMessage"] = "";
            TempData["MessageBody"] = "";
            try
            {
                if (ModelState.IsValid)
                {
                    if (string.IsNullOrEmpty(EventModel.EventDate.ToString()))
                    {
                        TempData["ShowMessage"] = "error";
                        TempData["MessageBody"] = "Please select a valid Event Date.";
                        return(View("Create", EventModel));
                    }

                    if (string.IsNullOrEmpty(EventModel.EventName))
                    {
                        TempData["ShowMessage"] = "error";
                        TempData["MessageBody"] = "Please Fill Event Name.";
                        return(View("Create", EventModel));
                    }

                    if (string.IsNullOrEmpty(EventModel.EventDescription))
                    {
                        TempData["ShowMessage"] = "error";
                        TempData["MessageBody"] = "Please Fill  EventDescription.";
                        return(View("Create", EventModel));
                    }
                    //CultureInfo culture = new CultureInfo("en-US");
                    //DateTime TodayDate = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"), culture);
                    //if (Convert.ToDateTime(EventModel.EventDate.ToString("MM/dd/yyyy"), culture) < TodayDate)
                    //{

                    //    TempData["ShowMessage"] = "error";
                    //    TempData["MessageBody"] = "You cannot add old date event.";
                    //    return View("Create", EventModel);
                    //}

                    Mapper.CreateMap <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>();
                    CommunicationApp.Entity.Event Event = Mapper.Map <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>(EventModel);
                    string EventImage = "";
                    if (file != null)
                    {
                        if (Event.EventImage != "")
                        {   //Delete Old Image
                            string pathDel = Server.MapPath("~/EventPhoto");

                            FileInfo objfile = new FileInfo(pathDel);
                            if (objfile.Exists) //check file exsit or not
                            {
                                objfile.Delete();
                            }
                            //End :Delete Old Image
                        }

                        //Save the photo in Folder
                        var    fileExt  = Path.GetExtension(file.FileName);
                        string fileName = Guid.NewGuid() + fileExt;
                        var    subPath  = Server.MapPath("~/EventPhoto");

                        //Check SubPath Exist or Not
                        if (!Directory.Exists(subPath))
                        {
                            Directory.CreateDirectory(subPath);
                        }
                        //End : Check SubPath Exist or Not

                        var path = Path.Combine(subPath, fileName);
                        file.SaveAs(path);

                        EventImage = CommonCls.GetURL() + "/EventPhoto/" + fileName;
                    }

                    Event.CustomerId = Convert.ToInt32(Session["CustomerId"]);//CutomerId
                    Event.IsActive   = true;
                    Event.CreatedOn  = DateTime.Now;
                    Event.EventImage = EventImage;
                    _EventService.InsertEvent(Event);
                    List <int> CustomerIds = new List <int>();
                    var        Customers   = new List <Customer>();
                    try
                    {
                        if (EventModel.All == true)
                        {
                            EventModel.SelectedCustomer = null;
                            Customers = _CustomerService.GetCustomers().ToList();
                            foreach (var Customer in Customers)
                            {
                                CustomerIds.Add(Convert.ToInt32(Customer.CustomerId));
                                EventCustomer EventCustomer = new Entity.EventCustomer();
                                EventCustomer.EventId    = Event.EventId;
                                EventCustomer.CustomerId = Customer.CustomerId;
                                _EventCustomerService.InsertEventCustomer(EventCustomer);
                            }
                        }
                        else if (EventModel.SelectedCustomer != null)
                        {
                            foreach (var Customer in EventModel.SelectedCustomer)
                            {
                                CustomerIds.Add(Convert.ToInt32(Customer));
                                EventCustomer EventCustomer = new Entity.EventCustomer();
                                EventCustomer.EventId    = Event.EventId;
                                EventCustomer.CustomerId = Event.CustomerId;
                                _EventCustomerService.InsertEventCustomer(EventCustomer);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLogging.LogError(ex);
                        throw;
                    }



                    string Flag    = "12";//status for Event;
                    var    Message = "New event saved.";
                    //send notification
                    try
                    {
                        var CustomerList = _CustomerService.GetCustomers().Where(c => CustomerIds.Contains(c.CustomerId) && c.CustomerId != EventModel.CustomerId && c.IsActive == true).ToList();
                        foreach (var Customer in CustomerList)
                        {
                            if (Customer != null)
                            {
                                if (Customer.ApplicationId != null && Customer.ApplicationId != "")
                                {
                                    bool NotificationStatus = true;

                                    string JsonMessage = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\"}";
                                    try
                                    {
                                        //Save Notification
                                        Notification Notification = new Notification();
                                        Notification.NotificationSendBy = 1;
                                        Notification.NotificationSendTo = Convert.ToInt32(Customer.CustomerId);
                                        Notification.IsRead             = false;
                                        Notification.Flag           = Convert.ToInt32(Flag);
                                        Notification.RequestMessage = Message;
                                        _Notification.InsertNotification(Notification);
                                        if (Customer.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                                        {
                                            CommonCls.SendGCM_Notifications(Customer.ApplicationId, JsonMessage, true);
                                        }
                                        else
                                        {
                                            int count = _Notification.GetNotifications().Where(c => c.NotificationSendTo == Convert.ToInt32(Customer.CustomerId) && c.IsRead == false).ToList().Count();
                                            //Dictionary<string, object> Dictionary = new Dictionary<string, object>();
                                            //Dictionary.Add("Flag", Flag);
                                            //Dictionary.Add("Message", Message);
                                            //NotificationStatus = PushNotificatinAlert.SendPushNotification(Customer.ApplicationId, Message, Flag, JsonMessage, Dictionary, 1, Convert.ToBoolean(Customer.IsNotificationSoundOn));
                                            CommonCls.TestSendFCM_Notifications(Customer.ApplicationId, JsonMessage, Message, count, true);
                                            ////Save Notification
                                            //Notification Notification = new Notification();
                                            //Notification.NotificationSendBy = 1;
                                            //Notification.NotificationSendTo = Customer.CustomerId;
                                            //Notification.IsRead = false;
                                            //Notification.RequestMessage = Message;
                                            //_Notification.InsertNotification(Notification);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        CommonCls.ErrorLog(ex.ToString());
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLogging.LogError(ex);
                        throw;
                    }

                    TempData["ShowMessage"] = "success";
                    TempData["MessageBody"] = "Event successfully saved.";
                    return(RedirectToAction("Index"));
                }
                var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
                var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);
                var CustomerList1    = _CustomerService.GetCustomers();
                EventModel.CustomersList = CustomerList1.Select(x => new SelectListItem {
                    Value = x.CustomerId.ToString(), Text = x.FirstName
                }).ToList();
                EventModel.CustomerId = 1;
                return(View(EventModel));
            }
            catch (Exception ex)
            {
                ErrorLogging.LogError(ex);

                return(View(EventModel));
            }
        }
Ejemplo n.º 26
0
        public ActionResult Create([Bind(Include = "ProductId,ProductName,Price,Size")] ProductsModel ProductModel, HttpPostedFileBase file)
        {
            UserPermissionAction("Category", RoleAction.view.ToString());
            CheckPermission();
            try
            {
                string URL = "";
                if (TempData["ImageUrl"] != null)
                {
                    URL = ViewBag.ImageUrl = (TempData["ImageUrl"]).ToString();
                }

                if (file != null && file.ContentLength > 0)
                {
                    try
                    {
                        if (file != null && file.ContentLength > 0)
                        {
                            string path = Path.Combine(Server.MapPath("~/ProductImage"), Path.GetFileName(file.FileName));
                            file.SaveAs(path);
                            URL = CommonCls.GetURL() + "/ProductImage/" + file.FileName;
                            ViewBag.ImageUrl = URL;
                        }
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message = "ERROR:" + ex.Message.ToString();
                    }
                }

                if (string.IsNullOrWhiteSpace(ProductModel.ProductName))
                {
                    ModelState.AddModelError("ProductName", "Please enter product name.");
                }
                if (ProductModel.Price == null)
                {
                    ModelState.AddModelError("Price", "Please enter price.");
                }
                if (ProductModel.Size.Count() == 0)
                {
                    ModelState.AddModelError("Size", "Please enter size.");
                }


                if (ModelState.IsValid)
                {
                    //var IsProductDuplicate = _ProductService.GetProducts().Where(c => c.ProductName == ProductModel.ProductName.Trim()).FirstOrDefault();
                    //if (IsProductDuplicate != null)
                    //{
                    //    TempData["ShowMessage"] = "error";
                    //    TempData["MessageBody"] = " Product name is already exist.";
                    //    return RedirectToAction("Create");
                    //}



                    Mapper.CreateMap <ProductsModel, Product>();
                    var    Product   = Mapper.Map <ProductsModel, Product>(ProductModel);
                    string Size      = "";
                    string FinalSize = "";
                    foreach (var item in ProductModel.Size)
                    {
                        if (item == 1)
                        {
                            Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.M);
                        }
                        else if (item == 2)
                        {
                            Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.L);
                        }
                        else if (item == 3)
                        {
                            Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XL);
                        }
                        else
                        {
                            Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XXL);
                        }
                        FinalSize = FinalSize + "," + Size;
                    }
                    Product.Size         = FinalSize.TrimEnd(',').TrimStart(',');
                    Product.productImage = URL;
                    _ProductService.InsertProduct(Product);
                    //new ProductModel
                    //{
                    //    ProductId = Convert.ToInt32(ProductModel.ProductId),
                    //    Name = ProductModel.Name,
                    //    Description=ProductModel.Description// ProductModel.ParentId == -1?null:Convert.ToInt32(ProductModel.ParentId)
                    //}.InsertUpdate();

                    TempData["ShowMessage"] = "success";
                    TempData["MessageBody"] = " Product save  successfully.";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.ProductList = Size.ToList();
                    return(View(ProductModel));
                }
            }


            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();//
                ErrorLogging.LogError(ex);
            }
            var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);

            return(View(ProductModel));
        }
Ejemplo n.º 27
0
        public ActionResult Edit([Bind(Include = "ProductId,ProductName,Price,Size")] ProductsModel ProductModel, HttpPostedFileBase file)
        {
            UserPermissionAction("Category", RoleAction.view.ToString());
            CheckPermission();
            try
            {
                string URL             = "";
                var    existingProduct = _ProductService.GetProducts().Where(c => c.ProductId == ProductModel.ProductId).FirstOrDefault();
                Mapper.CreateMap <HomeHelp.Models.ProductsModel, HomeHelp.Entity.Product>();
                HomeHelp.Entity.Product Products = Mapper.Map <HomeHelp.Models.ProductsModel, HomeHelp.Entity.Product>(ProductModel);
                if (existingProduct != null)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        try
                        {
                            if (existingProduct.productImage != "")
                            {
                                DeleteImage(existingProduct.productImage);
                            }

                            string path = Path.Combine(Server.MapPath("~/ProductImage"), Path.GetFileName(file.FileName));
                            file.SaveAs(path);

                            URL = CommonCls.GetURL() + "/ProductImage/" + file.FileName;
                            Products.productImage = URL;
                            _ProductService.UpdateProduct(Products);
                            ProductModel.productImage = URL;
                        }
                        catch (Exception ex)
                        {
                            ViewBag.Message = "ERROR:" + ex.Message.ToString();
                        }
                    }
                    else
                    {
                        ProductModel.productImage = Products.productImage = existingProduct.productImage;
                        _ProductService.UpdateProduct(Products);
                        Products.productImage = existingProduct.productImage;
                    }
                }

                if (string.IsNullOrWhiteSpace(ProductModel.ProductName))
                {
                    ModelState.AddModelError("ProductName", "Please enter product name.");
                }
                if (ProductModel.Price == null)
                {
                    ModelState.AddModelError("Price", "Please enter price.");
                }
                if (ProductModel.Size.Count() == 0)
                {
                    ModelState.AddModelError("Size", "Please enter size.");
                }
                if (ModelState.IsValid)
                {
                    //var IsParentAllReadyContainProductName = _ProductService.GetProducts().Where(c => c.ProductId != ProductModel.ProductId).Select(c => c.Name);
                    //if (IsParentAllReadyContainProductName.Contains(ProductModel.Name.Trim()))
                    //{
                    //    TempData["ShowMessage"] = "error";
                    //    TempData["MessageBody"] = " Product name is already exist.";
                    //    return RedirectToAction("Edit");
                    //}
                    //Product ProductFound = _ProductService.GetProducts().Where(x => x.Name == ProductModel.Name && x.ProductId != ProductModel.ProductId).FirstOrDefault();
                    if (existingProduct != null)
                    {
                        string Size      = "";
                        string FinalSize = "";
                        foreach (var item in ProductModel.Size)
                        {
                            if (item == 1)
                            {
                                Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.M);
                            }
                            else if (item == 2)
                            {
                                Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.L);
                            }
                            else if (item == 3)
                            {
                                Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XL);
                            }
                            else
                            {
                                Size = EnumValue.GetEnumDescription(EnumValue.ProductSizes.XXL);
                            }
                            FinalSize = FinalSize + "," + Size;
                        }
                        Products.Size = FinalSize.TrimEnd(',').TrimStart(',');
                        _ProductService.UpdateProduct(Products);

                        TempData["ShowMessage"] = "success";
                        TempData["MessageBody"] = " Product update  successfully.";
                        return(RedirectToAction("Index"));
                        // end  Update CompanyEquipments
                    }

                    else
                    {
                        TempData["ShowMessage"] = "error";
                        //if (ProductFound.Name.Trim().ToLower() == ProductModel.Name.Trim().ToLower()) //Check User Name
                        //{
                        //    TempData["MessageBody"] = ProductFound.Name + " already exist.";
                        //}

                        //else
                        //{
                        TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on ";
                        //}
                    }
                }
                else
                {
                    ViewBag.ProductList = Size.ToList();
                    return(View(ProductModel));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();//
                ErrorLogging.LogError(ex);
            }
            ViewBag.Product = new SelectList(_ProductService.GetProducts(), "ProductId", "Name", ProductModel.ProductId);
            var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);

            return(View(ProductModel));
        }
Ejemplo n.º 28
0
        public HttpResponseMessage SaveAttendence([FromBody] AttendenceModel AttendenceModel)
        {
            try
            {
                List <Attendence> model = new List <Attendence>();
                if (AttendenceModel.AbsentCustomerIds == null && AttendenceModel.AbsentCustomerIds == "" || AttendenceModel.PresentCustomerIds == null && AttendenceModel.PresentCustomerIds == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Absent or PresentCustomer Ids is blank."), Configuration.Formatters.JsonFormatter));
                }

                if (AttendenceModel.AttendenceDate == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Attendence Date is blank."), Configuration.Formatters.JsonFormatter));
                }

                var customerTeacher = _CustomerService.GetCustomer(AttendenceModel.TeacherId);
                if (customerTeacher == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "No teacher found."), Configuration.Formatters.JsonFormatter));
                }

                var CustomerList = _CustomerService.GetCustomers().Where(c => c.ParentId == AttendenceModel.TeacherId).ToList();
                if (CustomerList.Count() > 0)
                {
                    var CustomerIds = CustomerList.Select(s => s.CustomerId).ToList();
                    if (AttendenceModel.PresentCustomerIds != null && AttendenceModel.PresentCustomerIds != "")
                    {
                        var PresentCustomerIds = AttendenceModel.PresentCustomerIds.Split(',');
                        var PresentIds         = PresentCustomerIds.Select(int.Parse).ToList();
                        foreach (var item in PresentIds)
                        {
                            var attendenceFound = _AttendenceService.GetAttendences().Where(t => t.AttendenceDate == AttendenceModel.AttendenceDate && t.CustomerId == item && t.TeacherId == AttendenceModel.TeacherId).FirstOrDefault();
                            if (attendenceFound == null)
                            {
                                Mapper.CreateMap <Onlo.Models.AttendenceModel, Onlo.Entity.Attendence>();
                                Onlo.Entity.Attendence Attendence = Mapper.Map <Onlo.Models.AttendenceModel, Onlo.Entity.Attendence>(AttendenceModel);
                                Attendence.Status     = EnumValue.GetEnumDescription(EnumValue.AttendenceStatus.Present);
                                Attendence.CustomerId = item;
                                _AttendenceService.InsertAttendence(Attendence);
                                model.Add(Attendence);
                            }
                            else
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Attendence already marked."), Configuration.Formatters.JsonFormatter));
                            }
                        }
                    }

                    if (AttendenceModel.AbsentCustomerIds != null && AttendenceModel.AbsentCustomerIds != "")
                    {
                        var AbsentCustomerIds = AttendenceModel.AbsentCustomerIds.Split(',');
                        var AbsentIds         = AbsentCustomerIds.Select(int.Parse).ToList();
                        if (AbsentIds.Count() > 0)
                        {
                            foreach (var item in AbsentIds)
                            {
                                var attendenceFound = _AttendenceService.GetAttendences().Where(t => t.AttendenceDate == AttendenceModel.AttendenceDate && t.CustomerId == item && t.TeacherId == AttendenceModel.TeacherId).FirstOrDefault();
                                if (attendenceFound == null)
                                {
                                    Mapper.CreateMap <Onlo.Models.AttendenceModel, Onlo.Entity.Attendence>();
                                    Onlo.Entity.Attendence Attendence = Mapper.Map <Onlo.Models.AttendenceModel, Onlo.Entity.Attendence>(AttendenceModel);
                                    Attendence.Status     = EnumValue.GetEnumDescription(EnumValue.AttendenceStatus.Absent);
                                    Attendence.CustomerId = item;
                                    _AttendenceService.InsertAttendence(Attendence);
                                    model.Add(Attendence);
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Attendence already marked."), Configuration.Formatters.JsonFormatter));
                                }
                            }
                        }
                    }


                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", model), Configuration.Formatters.JsonFormatter));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "No teacher found."), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "please try again."), Configuration.Formatters.JsonFormatter));
            }
        }
Ejemplo n.º 29
0
        public void SendNotificationsToUsers(int CustomerId, string Heading, string Message, string ImageUrl, string IsWithImage, int count)
        {
            string Flag = "15";

            //send notification
            // var Customers = _CustomerService.GetCustomers().Where(c => c.CustomerId != CustomerId && c.IsActive == true).ToList();
            CommonClass CommonClass = new Services.CommonClass();
            string      QStr        = "";
            DataTable   dt          = new DataTable();

            QStr = "Select * From Customer where CustomerId = " + CustomerId + " and IsActive=1";
            dt   = CommonClass.GetDataSet(QStr).Tables[0];
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    var ApplicationId = dr["ApplicationId"].ToString();
                    var DeviceType    = dr["DeviceType"].ToString();
                    //var IsNotificationSoundOn = Convert.ToBoolean(dr["IsNotificationSoundOn"]);
                    var    IsNotificationSoundOn = true;
                    string sql = "insert into [notification](RequestMessage,NotificationSendTo,NotificationSendBy,Flag,IsRead) values(@RequestMessage,@NotificationSendTo,@NotificationSendBy,@Flag,@IsRead)";
                    try
                    {
                        string constring = ConfigurationManager.ConnectionStrings["DataContext"].ConnectionString;
                        using (SqlConnection con = new SqlConnection(constring))
                        {
                            using (SqlCommand cmd = new SqlCommand(sql, con))
                            {
                                cmd.CommandType = CommandType.Text;
                                cmd.Parameters.AddWithValue("@RequestMessage", Message);
                                cmd.Parameters.AddWithValue("@NotificationSendTo", dr["CustomerId"].ToString());
                                cmd.Parameters.AddWithValue("@NotificationSendBy", CustomerId);
                                cmd.Parameters.AddWithValue("@Flag", Flag);
                                cmd.Parameters.AddWithValue("@IsRead", false);
                                con.Open();
                                int rowsAffected = cmd.ExecuteNonQuery();
                                cmd.Dispose();
                                con.Close();
                                con.Dispose();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    if (ApplicationId != null && ApplicationId != "")
                    {
                        bool NotificationStatus = true;

                        string JsonMessage = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\",\"Heading\":\"" + Heading + "\",\"ImageUrl\":\"" + ImageUrl + "\",\"IsWithImage\":\"" + IsWithImage + "\"}";
                        if (DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                        {
                            CommonCls.SendGCM_Notifications(ApplicationId, JsonMessage, true);
                        }
                        else
                        {
                            string constring = ConfigurationManager.ConnectionStrings["DataContext"].ConnectionString;

                            using (SqlConnection con = new SqlConnection(constring))
                            {
                                con.Open();
                                using (SqlCommand thisCommand = new SqlCommand("SELECT COUNT(*) FROM Notification where NotificationSendTo=@NotificationSendTo and isread=0 ", con))
                                {
                                    thisCommand.Parameters.AddWithValue("@NotificationSendTo", Convert.ToInt32(dr["CustomerId"].ToString()));
                                    count = (int)(thisCommand.ExecuteScalar());
                                }

                                con.Close();
                                con.Dispose();
                            }
                            //Dictionary<string, object> Dictionary = new Dictionary<string, object>();
                            //Dictionary.Add("Flag", Flag);
                            //Dictionary.Add("Message", Message);
                            //NotificationStatus = PushNotificatinAlert.SendPushNotification(ApplicationId, Message, Flag.ToString(), JsonMessage, Dictionary, 1, Convert.ToBoolean(IsNotificationSoundOn));
                            CommonCls.TestSendFCM_Notifications(ApplicationId, JsonMessage, Message, count, true);
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
        public ActionResult Contact(string username, string lastname, string Email, string phn, string message, string UserType)
        {
            bool isSent = CommonClass.SendMailToAdmin(EnumValue.GetEnumDescription(EnumValue.EmailType.ContactUs), username + " " + lastname, Email, phn, "", "", message, UserType);

            return(Json("Success", JsonRequestBehavior.AllowGet));
        }