public async Task <IActionResult> CreateUpdate(int?id = null) { ViewBag.GendersList = MyEnumExtensions.EnumToSelectList <Gender>().ToList(); var model = new PersonCreateUpdateViewModel { Id = id, }; if (id != null) { var person = await _personService.GetByIdAsync(id.Value); if (person == null) { throw new Exception("Person Not Found"); } if (!string.IsNullOrEmpty(person.Avatar)) { ViewBag.AvatarPreview = "<img src=" + person.Avatar + " alt=\"Avatar\">"; } model = _mapper.Map <PersonCreateUpdateViewModel>(person); } return(PartialView("CreateUpdate", model)); }
public IActionResult Index() { ViewBag.Lang = Lng; ViewBag.Genders = MyEnumExtensions.EnumToSelectList <Gender>().ToList(); return(View(new PersonListViewModel())); }
public IActionResult Categories() { ViewBag.Lang = Lng; ViewBag.LayoutStyles = MyEnumExtensions.EnumToSelectList <ContentLayoutStyle>().ToList(); return(View(new CmsCategoryItemViewModel())); }
public IActionResult Index(PrescriptionStatus?currentStatus = null) { ViewBag.Lang = Lng; ViewBag.CurrentStatus = currentStatus; ViewBag.PrescriptionStatusList = MyEnumExtensions.EnumToSelectList <PrescriptionStatus>().ToList(); return(View(new PharmacyPrescriptionListViewModel())); }
public async Task <IActionResult> CreateUpdate(int?id = null) { ViewBag.OfferTypesList = MyEnumExtensions.EnumToSelectList <OfferType>().ToList(); ViewBag.Lang = Lng; ViewBag.HealthServices = _healthServiceService.GetShiftCenterServicesListItems(CurrentPolyclinic.Id, Lng).Select(x => new SelectListItem { Text = x.Text, Value = x.Value }).ToList(); ViewBag.Doctors = await _serviceSupplyService.GetSelectListAsync(CurrentPolyclinic.Id, CurrentPolyclinic.ServiceSupplyIds); var model = new OfferCreateUpdateViewModel { Id = id, Date = DateTime.Now.ToString("yyyy/MM/dd") }; if (id != null) { var offer = await _offerRepository.GetByIdAsync(id.Value); if (offer == null) { throw new Exception("Patient Not Found"); } model.Date = offer.StartDateTime.Value.ToShortDateString(); model.StartTime = offer.StartDateTime.Value.ToShortTimeString(); model.Endtime = offer.EndDateTime.Value.ToShortTimeString(); model.MaxCount = offer.MaxCount ?? 0; model.Description = offer.Description; model.ServiceSupplyId = offer.ServiceSupplyId; model.ShiftCenterServiceId = offer.ShiftCenterServiceId ?? 0; model.Type = offer.Type; model.SendNotification = offer.SendNotification; model.NotificationTitle = offer.NotificationTitle; model.NotificationTitle_Ku = offer.NotificationTitle_Ku; model.NotificationTitle_Ar = offer.NotificationTitle_Ar; model.NotificationBody = offer.NotificationBody; model.NotificationBody_Ku = offer.NotificationBody_Ku; model.NotificationBody_Ar = offer.NotificationBody_Ar; if (!string.IsNullOrEmpty(offer.Photo)) { ViewBag.PhotoPreview = "<img src=" + offer.Photo + " alt=\"Photo\">"; } } return(PartialView("CreateUpdate", model)); }
public async Task <IActionResult> Index(AppointmentStatus?currentStatus = null, string fromDate = "", string toDate = "") { ViewBag.Lang = Lng; ViewBag.Doctors = await _serviceSupplyService.GetSelectListAsync(CurrentBeautyCenter.Id, CurrentBeautyCenter.ServiceSupplyIds); ViewBag.CurrentStatus = currentStatus != null ? ((int)currentStatus).ToString() : ""; ViewBag.FromDate = fromDate; ViewBag.ToDate = toDate; ViewBag.StatusList = MyEnumExtensions.EnumToSelectList <AppointmentStatus>().ToList(); return(View(new BeautyCenterAppointmentListViewModel())); }
public async Task <IActionResult> CreateUpdateCategory(int?id) { var model = new ServiceCategoryViewModel(); if (id != null) { model = await _servicesService.GetServiceCategoryForCRUD(id.Value); if (!string.IsNullOrEmpty(model.Photo)) { ViewBag.AvatarPreview = "<img src=" + model.Photo + " alt=\"Avatar\">"; } } ViewBag.ShiftCenterTypes = MyEnumExtensions.EnumToSelectList <ShiftCenterType>().ToList(); return(PartialView(model)); }
public async Task <IActionResult> CreateUpdateArticle(int?id) { ViewBag.ReaderTypes = MyEnumExtensions.EnumToSelectList <ArticleReaderType>().ToList(); ViewBag.ContentCategories = await _dbContext.ContentCategories.Select(x => new SelectListItem { Value = x.Id.ToString(), Text = Lng == Lang.AR ? x.Title_Ar : Lng == Lang.KU ? x.Title_Ku : x.Title }).ToListAsync(); var model = new CmsArticleCreateUpdateViewModel { Id = id }; if (id != null) { var article = await _dbContext.ContentArticles.FindAsync(id); if (article == null) { throw new AwroNoreException("Article not found"); } if (!string.IsNullOrEmpty(article.ThumbnailUrl)) { ViewBag.AvatarPreview = "<img src=" + article.ThumbnailUrl + " alt=\"Image\">"; } if (!string.IsNullOrEmpty(article.ThumbnailUrl_Ku)) { ViewBag.AvatarPreviewKu = "<img src=" + article.ThumbnailUrl_Ku + " alt=\"Image\">"; } if (!string.IsNullOrEmpty(article.ThumbnailUrl_Ar)) { ViewBag.AvatarPreviewAr = "<img src=" + article.ThumbnailUrl_Ar + " alt=\"Image\">"; } model = _mapper.Map <CmsArticleCreateUpdateViewModel>(article); } return(PartialView(model)); }
public async Task <IActionResult> CreateUpdateCategory(int?id) { ViewBag.LayoutStyles = MyEnumExtensions.EnumToSelectList <ContentLayoutStyle>().ToList(); var model = new CmsCategoryCreateUpdateViewModel { Id = id }; if (id != null) { var category = await _dbContext.ContentCategories.FindAsync(id); if (category == null) { throw new AwroNoreException("Category not found"); } model = _mapper.Map <CmsCategoryCreateUpdateViewModel>(category); } return(PartialView(model)); }
public IActionResult Create(CreateCMUsersViewModel model) { try { string imagePath = string.Empty, newAvatarName = string.Empty; if (ModelState.IsValid) { if (model.ImageUpload != null && model.ImageUpload.Length > 0) { var validImageTypes = new string[] { "image/jpeg", "image/pjpeg", "image/png" }; if (!validImageTypes.Contains(model.ImageUpload.ContentType)) { ModelState.AddModelError("ImageUpload", Core.Resources.EntitiesResources.Messages.PleaseSelectPicWithSpecefiedFormat); throw new Exception(Core.Resources.EntitiesResources.Messages.PleaseSelectPicWithSpecefiedFormat); } var uploadDir = "wwwroot\\Content\\images\\avatars"; var fileExt = Path.GetExtension(model.ImageUpload.FileName)?.Substring(1); newAvatarName = "img_" + model.Mobile + "." + fileExt; imagePath = Path.Combine(Directory.GetCurrentDirectory(), uploadDir, newAvatarName); } var existsMobile = _dbContext.Persons.Where(u => u.Mobile == model.Mobile).Count() >= 1; if (existsMobile) { throw new Exception(Core.Resources.EntitiesResources.Messages.MobileNumberDuplicate); } //var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(_dbContext)); //var userManager = new UserManager<User>(new UserStore<User>(_dbContext)); var ClinicManagerRole = Shared.Enums.LoginAs.CLINICMANAGER.ToString(); var PolyClinicManagerRole = Shared.Enums.LoginAs.POLYCLINICMANAGER.ToString(); var DoctorRole = ""; var user = new Person { FirstName = model.FirstName, SecondName = model.SecondName, ThirdName = model.ThirdName, Age = model.Age ?? 0, Gender = model.Gender, Mobile = model.Mobile, ZipCode = model.ZipCode, Address = model.Address, Avatar = newAvatarName, //Email = "aw" + model.Mobile + "@awronore.krd", //UserName = model.Mobile, //ParentId = HttpContext.User.Identity.GetUserId(), CreatorRole = Shared.Enums.LoginAs.CLINICMANAGER, CreationPlaceId = CurrentClinic.Id, IsApproved = true, IsDeleted = false, CreatedAt = DateTime.Now }; #region Begin Transaction using (var transaction = _dbContext.Database.BeginTransaction(System.Data.IsolationLevel.ReadCommitted)) { try { //Generate random password var RandomPassword = "******"; //System.Web.Security.Membership.GeneratePassword(8, 0); _userService.InsertNewPerson(user); //foreach (var role in model.Roles) //{ // switch (role) // { // case 2: // var assignClinicManagerRole = userManager.AddToRole(user.Id, ClinicManagerRole); // if (!assignClinicManagerRole.Succeeded) // { // throw new Exception(Core.Resources.EntitiesResources.Messages.ErrorOccuredWhileAssignRole); // } // break; // case 3: // var assignPolyClinicManagerRole = userManager.AddToRole(user.Id, PolyClinicManagerRole); // if (!assignPolyClinicManagerRole.Succeeded) // { // throw new Exception(Core.Resources.EntitiesResources.Messages.ErrorOccuredWhileAssignRole); // } // break; // case 4: // var assignDoctorRole = userManager.AddToRole(user.Id, DoctorRole); // if (!assignDoctorRole.Succeeded) // { // throw new Exception(Core.Resources.EntitiesResources.Messages.ErrorOccuredWhileAssignRole); // } // _dbContext.UserDoctorInfoes.Add(new UserDoctorInfo // { // UserDoctorId = user.Id, // MedicalCouncilNumber = model.DocotrMedicalCouncilNumber, // Picture = newAvatarName, // CreatedAt = DateTime.Now // }); // break; // } //} _dbContext.ClinicPersons.Add(new ClinicPersons { Clinic_Id = CurrentClinic.Id, PersonId = user.Id, IsManager = false, CreatedAt = DateTime.Now }); if (CurrentClinic != null && !CurrentClinic.IsIndependent) { _dbContext.HospitalPersons.Add(new HospitalPersons { HospitalId = (int)CurrentClinic.HospitalId, PersonId = user.Id, IsManager = false, CreatedAt = DateTime.Now }); } _dbContext.SaveChanges(); if (!imagePath.Equals(string.Empty) && imagePath != null) { using (var stream = new FileStream(imagePath, FileMode.Create)) { model.ImageUpload.CopyTo(stream); } } transaction.Commit(); TempData.Put("message", new MVCResultModel { status = MVCResultStatus.success, message = Core.Resources.EntitiesResources.Messages.ItemAddedSuccessFully }); return(RedirectToAction("Index", "Users", new { area = "ClinicManager" })); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); transaction.Rollback(); } } #endregion } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } ViewBag.Genders = MyEnumExtensions.EnumToSelectList <Gender>().ToList(); return(View(model)); }
public IActionResult Create() { ViewBag.Genders = MyEnumExtensions.EnumToSelectList <Gender>().ToList(); return(View(new CreateCMUsersViewModel())); }