ActionOutput <UserModel> IUserManager.AuthenticateUser(LoginModel model) { ActionOutput <UserModel> res = new ActionOutput <UserModel>(); try { var HashPass = UtilitiesHelp.EncryptPassword(model.ContactNo, true); var exists = Context.UserTbls.Where(p => p.Phone == model.ContactNo && p.Password == HashPass && (p.Status == (int)UserStatuss.Approved || p.Status != (int)UserStatuss.Subscribed)).FirstOrDefault(); if (exists != null) { res.Object = new UserModel(exists); res.Status = ActionStatus.Successfull; res.Message = "Login Successfull"; } else { res.Status = ActionStatus.Error; res.Message = "User doesn't exists"; } } catch (Exception ex) { res.Status = ActionStatus.Error; res.Message = "Some Error Occurred"; } return(res); }
ActionOutput <UserModel> IUserManager.RegisterUser(UserModel model) { ActionOutput <UserModel> res = new ActionOutput <UserModel>(); try { var Phone_Exists = Context.UserTbls.Where(p => p.Phone == model.Phone && p.Status != (int)UserStatuss.Deleted).Any(); if (!Phone_Exists) { UserTbl _user = new UserTbl(); _user.FirstName = model.FirstName; _user.LastName = model.LastName; _user.Phone = model.Phone; _user.Email = model.Email; _user.Password = UtilitiesHelp.EncryptPassword(model.Password, true); _user.RoleId = model.RoleId; _user.Address = model.Address; _user.City = model.City; _user.Latitute = model.Latitute; _user.Longitute = model.Longitute; _user.Province = model.Province; _user.OTP = UtilitiesHelp.GenerateOTP(); _user.Status = (int)UserStatuss.Registered; _user.CreatedOn = DateTime.Now; Context.UserTbls.Add(_user); Context.SaveChanges(); //DEV const string accountSid = "AC3d3a026d31db3d33865fbf53259a0000"; const string authToken = "685ce72fc4d6b7c61d9804802de34c81"; //LIVE //const string accountSid = "ACa8fc7a52b4ee46f45cfc07c1cccf5137"; //const string authToken = "3c83a5093211b78584f34265691163dd"; TwilioClient.Init(accountSid, authToken); var message = MessageResource.Create( body: "OTP for ApniMaa app is ." + _user.OTP, from: new Twilio.Types.PhoneNumber("+12063374541"), to: new Twilio.Types.PhoneNumber("+91" + _user.Phone) ); res.Object = new UserModel(_user); res.Status = ActionStatus.Successfull; res.Message = "User Registered successfully"; } else { res.Status = ActionStatus.Error; res.Message = "Phone Number already registered."; } } catch (Exception ex) { res.Status = ActionStatus.Error; res.Message = "Some Errpr Occurred"; } return(res); }
ActionOutput <UserModel> IUserManager.VeifyOTP(OTPModel model) { ActionOutput <UserModel> res = new ActionOutput <UserModel>(); try { var user = Context.UserTbls.Where(p => p.Id == model.Id && p.Status == (int)UserStatuss.Registered).FirstOrDefault(); if (user != null) { if (user.OTP == model.OTP.ToString()) { if (user.RoleId == (int)UserRoleTypes.Mother) { user.Status = (int)UserStatuss.Verified; MotherTbl _mother = new MotherTbl(); _mother.ApplicationNo = UtilitiesHelp.GenerateApplicationNo(); _mother.UserId = user.Id; _mother.WalletAmount = 0; _mother.Commision = 0; _mother.Ratings = 0; Context.MotherTbls.Add(_mother); Context.SaveChanges(); res.Object = new UserModel(user); res.Status = ActionStatus.Successfull; res.Message = "Mother Verified successfully. Wait for Admin approval."; } else { user.Status = (int)UserStatuss.Approved; Context.SaveChanges(); res.Object = new UserModel(user); res.Status = ActionStatus.Successfull; res.Message = "User Verified successfully"; } } else { res.Status = ActionStatus.Error; res.Message = "Incorrect OTP."; } } else { res.Status = ActionStatus.Error; res.Message = "User doesnt exists."; } } catch (Exception ex) { res.Status = ActionStatus.Error; res.Message = "Some Errpr Occurred"; } return(res); }
internal AddEditEmailTemplateModel(EmailTemplate emailTemplate) { this.TemplateId = emailTemplate.TemplateId; this.TemplateName = emailTemplate.TemplateName; this.EmailSubject = emailTemplate.EmailSubject; this.TemplateContent = emailTemplate.TemplateContent; this.TemplateType = emailTemplate.TemplateType; this.TemplateStatus = emailTemplate.TemplateStatus; this.TemplateTypeList = new List <SelectListItem>(); this.TemplateTypeList = UtilitiesHelp.EnumToList(typeof(TemplateTypes)); }
ActionOutput IUserManager.AddDishForMother(AddDishForMotherModel model) { var GetMotherID = Context.MotherTbls.Where(a => a.UserId == model.MotherID).FirstOrDefault().Id; var ExistingDish = Context.MotherDishes.Where(a => a.MotherId == GetMotherID && a.DishId == model.DishId && a.IsDeleted == false ).FirstOrDefault(); if (ExistingDish != null) { return(new ActionOutput { Status = ActionStatus.Error, Message = "Dish Already Exists." }); } string FileName = ""; if (model.DishImage != null) { FileName = UtilitiesHelp.SavePostedFile(AppFolderName.DishImage, model.DishImage); } var MotherDish = new MotherDish { MotherId = GetMotherID, DishId = model.DishId, Image = FileName, Limit = 100, Price = 200, CreatedOn = DateTime.Now, IsDeleted = false, IsMainDish = false, IsSignatureDish = false }; Context.MotherDishes.Add(MotherDish); Context.SaveChanges(); // return new ActionOutput // { // Status = ActionStatus.Error, // Message = "This Part already exists." // }; return(new ActionOutput { Status = ActionStatus.Successfull, Message = "Dish Added Successfully." }); }
public MotherDishModel(MotherDish obj) { this.Id = obj.Id; this.MotherId = obj.MotherId; this.DishId = obj.DishId; this.DishName = obj.Dish.Name; this.Limit = obj.Limit; this.Price = obj.Price; this.Image = UtilitiesHelp.GetFilePath(AppFolderName.DishImage, obj.Image); this.CreatedOn = obj.CreatedOn.ToString(AppDefaults.DateTimeFormat); this.IsDeleted = obj.IsDeleted; this.IsMainDish = obj.IsMainDish; this.IsSignatureDish = obj.IsSignatureDish; }
ActionOutput IUserManager.PhoneLogin(LoginModel model) { ActionOutput res = new ActionOutput(); try { var exists = Context.UserTbls.Where(p => p.Phone == model.ContactNo && (p.Status == (int)UserStatuss.Approved || p.Status != (int)UserStatuss.Subscribed)).FirstOrDefault(); if (exists != null) { //LIVE //const string accountSid = "ACa8fc7a52b4ee46f45cfc07c1cccf5137"; //const string authToken = "3c83a5093211b78584f34265691163dd"; exists.OTP = UtilitiesHelp.GenerateOTP(); Context.SaveChanges(); //DEV const string accountSid = "AC3d3a026d31db3d33865fbf53259a0000"; const string authToken = "685ce72fc4d6b7c61d9804802de34c81"; //LIVE //const string accountSid = "ACa8fc7a52b4ee46f45cfc07c1cccf5137"; //const string authToken = "3c83a5093211b78584f34265691163dd"; TwilioClient.Init(accountSid, authToken); var message = MessageResource.Create( body: "OTP for ApniMaa app is ." + exists.OTP, from: new Twilio.Types.PhoneNumber("+12063374541"), to: new Twilio.Types.PhoneNumber("+91" + exists.Phone) ); res.Status = ActionStatus.Successfull; res.Message = "OTP Sent"; } else { res.Status = ActionStatus.Error; res.Message = "Contact No. not registered."; } } catch (Exception ex) { res.Status = ActionStatus.Error; res.Message = "Some Error Occurred"; } return(res); }
public UserModel(UserTbl obj) { this.UserID = obj.Id; this.RoleId = obj.RoleId; this.RoleName = UtilitiesHelp.EnumToDecription(typeof(UserRoleTypes), obj.RoleId.Value); this.Email = obj.Email; this.FirstName = obj.FirstName; this.LastName = obj.LastName; this.Password = UtilitiesHelp.EncryptPassword(obj.Password, true); this.Phone = obj.Phone; this.City = obj.City; this.Province = obj.Province; this.Address = obj.Address; this.Longitute = obj.Longitute; this.Latitute = obj.Latitute; this.RoleId = obj.RoleId; this.Status = obj.Status; }
ActionOutput <UserModel> IUserManager.AdminLogin(LoginModal model) { ActionOutput <UserModel> res = new ActionOutput <UserModel>(); try { model.Password = UtilitiesHelp.EncryptPassword(model.Password, true); //var HashPass = EncryptionHelper.EncryptToByte(model.Password); var user = Context.UserTbls.Where(p => p.Email == model.UserName && p.Password == model.Password && p.RoleId == (int)UserRoleTypes.Admin).FirstOrDefault(); if (user != null) { //user.IsPermissonUpdated = false; Context.SaveChanges(); res.Status = ActionStatus.Successfull; res.Message = "Login Success"; res.Object = new UserModel { UserID = user.Id, FirstName = user.FirstName, LastName = user.LastName, }; } else { res.Status = ActionStatus.Error; res.Message = "User Does Not Exists"; } } catch (Exception ex) { res.Status = ActionStatus.Error; res.Message = "Some Error Occurred"; } return(res); }
public AddEditEmailTemplateModel() { this.TemplateStatus = true; this.TemplateTypeList = new List <SelectListItem>(); this.TemplateTypeList = UtilitiesHelp.EnumToList(typeof(TemplateTypes)); }
ActionOutput <List <MotherDish> > IHomeManager.GetAmazingDishesList(double Longitute, double Latitute, DateTime ReqDate, int CategoryId, int AvailabiltyTypes) { ActionOutput <List <MotherDish> > res = new ActionOutput <List <MotherDish> >(); try { var datas = (from m in Context.MotherTbls join u in Context.UserTbls on m.UserId equals(u.Id) where (u.Status == (int)UserStatuss.Approved || u.Status == (int)UserStatuss.Subscribed)select new { m, u }).ToList(); var data = new List <MotherTbl>(); foreach (var item in datas) { if (UtilitiesHelp.HaversineDistance(new LatLng(Convert.ToDouble(item.u.Latitute), Convert.ToDouble(item.u.Longitute)), new LatLng(Latitute, Longitute)) <= 5) { data.Add(item.m); } } var DaySchedule = Context.MotherDailySchedules.Where(p => p.Date == ReqDate).AsQueryable(); if (AvailabiltyTypes == (int)AvailibiltyType.Dinner) { DaySchedule = DaySchedule.Where(p => p.Type == (int)AvailibiltyType.Both && p.Type == (int)AvailibiltyType.Dinner).AsQueryable(); } else { DaySchedule = DaySchedule.Where(p => p.Type == (int)AvailibiltyType.Both && p.Type == (int)AvailibiltyType.Lunch).AsQueryable(); } List <MotherTbl> _mothers = new List <MotherTbl>(); foreach (var item in data) { var s = DaySchedule.Where(p => p.MotherId == item.Id).FirstOrDefault(); if (s != null) { if (s.Availabilty == true) { _mothers.Add(item); } } } var DailyDishSchedule = Context.MotherDishDailySchedules.Where(p => p.Date == DateTime.Now).AsQueryable(); List <MotherTbl> _fmothers = new List <MotherTbl>(); foreach (var item in _mothers) { var s = DailyDishSchedule.Where(p => p.MotherDish.MotherId == item.Id).ToList(); if (s.Count != 0) { foreach (var items in s) { if (items.Availabilty == true) { if (!_fmothers.Contains(item)) { if (CategoryId != 0) { if (items.MotherDish.Dish.CategoryId == CategoryId) { _fmothers.Add(item); } } else { _fmothers.Add(item); } } } } } } List <MotherDish> model = new List <MotherDish>(); foreach (var item in _fmothers) { MotherDish mm = new MotherDish(); mm = DailyDishSchedule.Where(p => p.MotherDish.MotherId == item.Id && p.Availabilty == true).Select(p => p.MotherDish).OrderBy(p => p.Id).FirstOrDefault(); model.Add(mm); } res.Object = model; res.Message = "Data Fetched Successfully"; res.Status = ActionStatus.Successfull; } catch (Exception ex) { res.Status = ActionStatus.Error; res.Message = "Some Error Occurred"; } return(res); }