public async Task <IActionResult> Edit(AdminDoctorDto model)
        {
            if (!ModelState.IsValid)
            {
                await ShowHospitalList(false);

                ViewBag.SexList      = EnumExtensionHelper.EnumToSelectList <SexEnum>(false);
                ViewBag.UserTypeList = EnumExtensionHelper.EnumToSelectList <UserTypeEnum>(false);
                ViewBag.DeptList     = EnumExtensionHelper.EnumToSelectList <DeptEnum>(false);
                ViewBag.TitleList    = EnumExtensionHelper.EnumToSelectList <TitleEnum>(false);
                return(PartialView("_EditPartial", model));
            }

            if (model.HospitalId < 1 && !CurrentLoginUser.IsSuperManager)
            {
                model.HospitalId = CurrentLoginUser.HospitalId.Value;
            }

            //主键初始Id大于0表示是编辑,反之则是新增
            if (model.Id > 0)
            {
                var result = await _service.Update(model);

                return(Json(result));
            }
            else
            {
                var result = await _service.Add(model);

                return(Json(result));
            }
        }
Ejemplo n.º 2
0
 public ActionResult CreateNew([Bind(Include = "Id,Name,Surname,Email,Phone,TitleId")] Doctor doctor)
 {
     if (ModelState.IsValid)
     {
         doctorService.Add(doctor);
         return(RedirectToAction("Index"));
     }
     ViewBag.TitleId  = new SelectList(db.Titles, "Id", "Title", doctor.TitleId);//title bu bilgilerle eklenir.
     TempData["Info"] = "Record successfully added to database";
     return(View(doctor));
 }
Ejemplo n.º 3
0
        public bool Add()
        {
            try
            {
                this.UserId = AuthenticatedDoctorUserModel.GetUserFromIdentity().Id;
                this.DoctorChamberRelations   = this.ChamberSelectedIdsToDoctorChamberRelations().ToList();
                this.DoctorSpecialtyRelations = this.SpecialtySelectedIdsToDoctorSpecialtyRelations().ToList();
                this.DoctorDegreeRelations    = this.DegreeSelectedIdsToDoctorDegreeRelations().ToList();
                this.ImageUrl = CustomFile.SaveImageFile(this.ImageFileBase,
                                                         AuthenticatedDoctorUserModel.GetUserFromIdentity().Name,
                                                         AuthenticatedDoctorUserModel.GetUserFromIdentity().Id, "Doctor");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            return(_doctorService.Add(this));
        }
 public void Add(Doctor doctor)
 {
     _doctorService.Add(doctor);
 }
Ejemplo n.º 5
0
 public Doctor Add(Doctor doctor)
 {
     return(_doctorService.Add(doctor));
 }