private ValueItem[] GetTreatmentCategoryList() { var categoryManager = new TreatmentCategoryManager(); return(categoryManager.GetAll().Select(c => new ValueItem { Id = c.Id, Name = c.Name }) .OrderBy(c => c.Name) .ToArray()); }
protected override void Seed(ApplicationDbContext context) { //default roles var superUserRole = new Role { Name = "SuperUser" }; var staffRole = new Role { Name = "Staff" }; var userRole = new Role { Name = "Client" }; var roleManager = new DatabaseContext.Models.RoleManager <Role>(new RoleStore(context)); roleManager.Create(superUserRole); roleManager.Create(staffRole); roleManager.Create(userRole); //default users var UserManager = new UserManager <User, int>(new UserStore(context)); var PasswordHash = new PasswordHasher(); //SuperUser if (!context.Users.Any(u => u.UserName == "*****@*****.**")) { var user = new User { UserName = "******", Email = "*****@*****.**", PasswordHash = PasswordHash.HashPassword("123456") }; UserManager.Create(user); UserManager.AddToRole(user.Id, superUserRole.Name); } //staff Dr.Akula if (!context.Users.Any(u => u.UserName == "*****@*****.**")) { var user = new User { UserName = "******", Email = "*****@*****.**", PasswordHash = PasswordHash.HashPassword("123456") }; UserManager.Create(user); UserManager.AddToRole(user.Id, staffRole.Name); } //User Alice if (!context.Users.Any(u => u.UserName == "*****@*****.**")) { var user = new User { UserName = "******", Email = "*****@*****.**", PasswordHash = PasswordHash.HashPassword("123123"), LockoutEnabled = false }; UserManager.Create(user); UserManager.AddToRole(user.Id, userRole.Name); } //User Carry if (!context.Users.Any(u => u.UserName == "*****@*****.**")) { var user = new User { UserName = "******", Email = "*****@*****.**", PasswordHash = PasswordHash.HashPassword("123123"), LockoutEnabled = false }; UserManager.Create(user); UserManager.AddToRole(user.Id, userRole.Name); } //default clinic if (!context.Clinics.Any(n => n.BusinessName == "Miricos Aesthetics Clinic")) { var now = DateTime.Now; var hours = new List <ClinicHours>() { new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), Day = DayOfWeek.Tuesday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), Day = DayOfWeek.Wednesday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), Day = DayOfWeek.Thursday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), Day = DayOfWeek.Friday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 16, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 16, 0, 0, 0), Day = DayOfWeek.Saturday } }; var clinicManager = new ClinicManager(); var newClinic = clinicManager.CreateOrUpdate(new Clinic { BusinessName = "Miricos Aesthetics Clinic", ShortName = "MAS", BusinessAddress = "Level 2, 340 Collins Street, Melbourne VIC 3000", OwnersName = "Ricky Lee", OwnersEmailAddress = "*****@*****.**", OwnersPhoneNumber = "+61435782764", BusinessWebsiteAddress = "www.miricos.com.au", EmailAddressForOnlineBookings = "*****@*****.**", DirectPhoneToTheLocation = "03 9913 7362", ContactPerson = "Kitshi Hui", StoreManagerPhoneNumber = "03 9913 7362", WebsiteLocationAddress = "Level 2, 340 Collins Street, Melbourne VIC 3000", IsActive = true, City = "Melbourne", State = "VIC 3000", Address = "Level 2, 340 Collins Street, Melbourne VIC 3000", Email = "*****@*****.**", Hours = hours, BankAccountName = "Miricos Pty Ltd.", BankBsb = "013257", BankAccountNumber = "398887026" }); } if (!context.Clinics.Any(n => n.BusinessName == "Esteem Hair Beauty Spa")) { var now = DateTime.Now; var hours = new List <ClinicHours>() { new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 30, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 30, 0, 0), Day = DayOfWeek.Monday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 30, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 30, 0, 0), Day = DayOfWeek.Tuesday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 19, 0, 0, 0), Day = DayOfWeek.Wednesday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 21, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 21, 0, 0, 0), Day = DayOfWeek.Thursday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 30, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 30, 0, 0), Day = DayOfWeek.Friday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 8, 30, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 16, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 8, 30, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 16, 0, 0, 0), Day = DayOfWeek.Saturday } }; var clinicManager = new ClinicManager(); var newClinic = clinicManager.CreateOrUpdate(new Clinic { BusinessName = "Esteem Hair Beauty Spa", ShortName = "EHBS", BusinessAddress = "Shop 15 Tattersalls Centre 510 - 536 High Street Penrith NSW 2750", ABN = "73518997490", OwnersName = "Martin Lazare", OwnersEmailAddress = "*****@*****.**", OwnersPhoneNumber = "402068707", BusinessWebsiteAddress = "www.esteemhairbeautyspa.com.au", EmailAddressForOnlineBookings = "*****@*****.**", DirectPhoneToTheLocation = "(02) 47223250", ContactPerson = "Martin Lazare", StoreManagerPhoneNumber = "402068707", WebsiteLocationAddress = "Shop 15 Tattersalls Centre 510 - 536 High Street Penrith NSW 2750", IsActive = true, City = "Penrith", State = "NSW 2750", Address = "Shop 15 Tattersalls Centre 510 - 536 High Street Penrith NSW 2750", Email = "*****@*****.**", Hours = hours, BankAccountName = "Esteem Hair Beauty Spa", BankBsb = "12429", BankAccountNumber = "457356912", HowToFind = "Centrally Located on High Street Penrtih across the road from Trade Secret and within 2 minutes walk of Westfield shopping centre. Best parking union lane carpark behind the tattersalls centre." }); } if (!context.Clinics.Any(n => n.BusinessName == "Sunlounge tanning and beauty")) { var now = DateTime.Now; var hours = new List <ClinicHours>() { new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), Day = DayOfWeek.Tuesday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), Day = DayOfWeek.Wednesday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), Day = DayOfWeek.Thursday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 21, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 21, 0, 0, 0), Day = DayOfWeek.Friday }, new ClinicHours { BookingOpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), BookingCloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), OpenHour = new DateTime(now.Year, now.Month, now.Day, 9, 0, 0, 0), CloseHour = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0, 0), Day = DayOfWeek.Saturday } }; var clinicManager = new ClinicManager(); var newClinic = clinicManager.CreateOrUpdate(new Clinic { BusinessName = "Sunlounge tanning and beauty", ShortName = "STB", BusinessAddress = "43 the parade norwood SA 5067", ABN = "30605284124", OwnersName = "Daniel Borg", OwnersEmailAddress = "*****@*****.**", OwnersPhoneNumber = "405529989", BusinessWebsiteAddress = "sunloungetanningandbeauty.com.au", EmailAddressForOnlineBookings = "*****@*****.**", DirectPhoneToTheLocation = "08 83626211", ContactPerson = "Amy Minervini", StoreManagerPhoneNumber = "08 83626211", WebsiteLocationAddress = "sunloungetanningandbeauty.com.au", IsActive = true, City = "Norwood", State = "SA 5067", Address = "43 the parade norwood SA 5067", Email = "sunloungetanningandbeauty.com.au", Hours = hours, BankAccountName = "Rejuv cosmedical", BankBsb = "065-115", BankAccountNumber = "1040 7681", HowToFind = "On the cnr of the Parade and Sydenham road Norwood." }); } //Treatment category if (!context.TreatmentCategories.Any(n => n.Name == "Whitening")) { var manager = new TreatmentCategoryManager(); var categoryId = manager.CreateOrUpdate(new TreatmentCategory() { Description = "Whitening", Name = "Whitening", PictureUrl = "Whitening" }); var treatmentManager = new TreatmentManager(); var url = "http://drperrone.com/blog/wp-content/uploads/2012/06/smiles-300x300.jpg"; treatmentManager.CreateOrUpdate(new Treatment() { Name = "Whitening", Description = "Whitening", PictureUrl = url, Price = 120, TreatmentCategoryId = categoryId }); } }
public ActionResult Save(TreatmentEditItem treatment) { if (ModelState.IsValid) { if (!FileHelper.ValidateIfImage(ControllerContext.HttpContext.Request.Files)) { ModelState.AddModelError(string.Empty, $"Input image should be in ({ConfigurationManager.AllowedImageFormats}) formats only."); treatment.TreatmentCategoryList = GetTreatmentCategoryList(); return(View("TreatmentEditView", treatment)); } var oldPictureUrl = treatment.PictureUrl; var newTreatment = new Treatment { Id = treatment.Id, Name = treatment.Name, Description = treatment.Description, Price = treatment.Price, TreatmentCategoryId = treatment.TreatmentCategoryId, IsActive = treatment.IsActive, DurationId = (int)treatment.DurationId }; bool hasError = false; try { if (ControllerContext.HttpContext.Request.Files.Count > 0 && ControllerContext.HttpContext.Request.Files[0] != null && ControllerContext.HttpContext.Request.Files[0].ContentLength > 0) // new file posted. Remove old one. { newTreatment.PictureUrl = FileHelper.SaveFile(ControllerContext); FileHelper.DeleteFile(oldPictureUrl); } else { newTreatment.PictureUrl = treatment.PictureUrl; } } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); hasError = true; } Manager.CreateOrUpdate(newTreatment); if (hasError) { treatment.TreatmentCategoryList = GetTreatmentCategoryList(); return(View("TreatmentEditView", treatment)); } return(RedirectToAction("TreatmentList", "Treatment")); } var categoryManager = new TreatmentCategoryManager(); treatment.TreatmentCategoryList = categoryManager.GetAll().Select(c => new ValueItem { Id = c.Id, Name = c.Name }).ToArray(); return(View("TreatmentEditView", treatment)); }