Exemple #1
0
        public async Task <ActionResult> CreateSpeciality(SpecialityViewModel speciality)
        {
            string currentUserId = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if (currentUserId == null)
            {
                return(new HttpUnauthorizedResult());
            }
            ViewBag.SubjectName = (await SubjectService.GetAsync(speciality.SubjectId)).SubjectName;
            ViewBag.ParentId    = speciality.SubjectId;
            ViewBag.Action      = "SubjectSpecialities";
            if (ModelState.IsValid)
            {
                SpecialityDTO specialityDTO = new SpecialityDTO
                {
                    SubjectId      = speciality.SubjectId,
                    SpecialityName = speciality.Name,
                    Description    = speciality.Description,
                    IsApproved     = speciality.IsApproved
                };
                OperationDetails operationDetails = await SpecialityService.CreateAsync(specialityDTO, currentUserId);

                if (operationDetails.Succedeed)
                {
                    return(PartialView("Report", operationDetails));
                }
                else
                {
                    ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
                    return(PartialView("Report", operationDetails));
                }
            }
            ViewBag.Message = "Non valid";
            return(PartialView("~/Views/Admin/Speciality/CreateSpeciality.cshtml", speciality));
        }
Exemple #2
0
        /// <summary>
        /// Returns the specialities
        /// </summary>
        /// <param name="fromClient"></param>
        /// <returns></returns>
        public List <SpecialityViewModel> GetSpecialities(bool fromClient)
        {
            try
            {
                List <SpecialityViewModel> specialities = new List <SpecialityViewModel>();
                List <BusinessModel.BusinessModels.Speciality> specialitiesDTO = _specialityRespository.GetSpecialities();
                foreach (BusinessModel.BusinessModels.Speciality specialityDTO in specialitiesDTO)
                {
                    SpecialityViewModel speciality = new SpecialityViewModel();
                    speciality.SpecialityCode        = specialityDTO.SpecialityCode;
                    speciality.SpecialityName        = specialityDTO.SpecialityName;
                    speciality.SpecialityDescription = specialityDTO.SpecialityDescription;
                    speciality.RecordStatus          = specialityDTO.RecordStatus;
                    speciality.ID      = specialityDTO.ID;
                    speciality.Clients = GetClientsAssociatedWithSpecialty(speciality.ID, false);

                    specialities.Add(speciality);
                }
                return(fromClient ? specialities.OrderBy(s => s.SpecialityName).ToList() : specialities);
            }
            catch (Exception ex)
            {
                _logger.Log(ex, LogLevel.Error, ex.Message);
                return(null);
            }
        }
Exemple #3
0
        public async Task <IActionResult> Add(SpecialityViewModel model)
        {
            // TODO: РОЛИ РОЛИ РОЛИ
//            string nikita = _userManager.GetUserId(HttpContext.User);
//            ViewBag.nikita = nikita;
//            if (nikita != "87759cdf-3b58-483b-a738-f79a051bac23" && nikita != "4d980ae0-2592-43fa-a2c1-35f8789102b7")
//            {
//                return NotFound();
//            }
            if (ModelState.IsValid)
            {
                foreach (var name in model.Names)
                {
                    Speciality spec = new Speciality
                    {
                        Name = name
                    };
                    await _db.Specialities.AddAsync(spec);

                    await _db.SaveChangesAsync();
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemple #4
0
        // Delete a speciality.
        public async Task <ActionResult> DeleteSpeciality(int?id)
        {
            // Check id.
            if (!int.TryParse(id.ToString(), out int intId))
            {
                return(RedirectToAction("Index"));
            }
            // Get SpecialityDTO object.
            SpecialityDTO specialityDTO = await SpecialityService.GetAsync(intId);

            if (specialityDTO == null)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.SubjectName = specialityDTO.Subject.SubjectName;
            ViewBag.ParentId    = specialityDTO.SubjectId;
            // AutoMapper Setup.
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <SpecialityDTO, SpecialityViewModel>()
                .ForMember("Id", opt => opt.MapFrom(obj => obj.SpecialityId))
                .ForMember("Name", opt => opt.MapFrom(obj => obj.SpecialityName));
            });
            IMapper             iMapper    = config.CreateMapper();
            SpecialityViewModel speciality = iMapper.Map <SpecialityDTO, SpecialityViewModel>(specialityDTO);

            return(PartialView("~/Views/Admin/Speciality/DeleteSpeciality.cshtml", speciality));
        }
Exemple #5
0
        private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SpecialityViewModel speciality = getViewModelfromRowData();

            try
            {
                DialogResult result = MessageBox.Show(
                    "Esta seguro que desea eliminar este elemento",
                    "Alerta!",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    var especialidad = context.Speciality
                                       .Where(x => x.SpecialityId.Equals(speciality.Id))
                                       .SingleOrDefault();

                    context.Speciality.Remove(especialidad);
                    context.SaveChanges();

                    updateDGVEspecialidades();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ocurrio un problema");
            }
        }
Exemple #6
0
        private SpecialityViewModel getViewModelfromRowData()
        {
            SpecialityViewModel speciality = new SpecialityViewModel();

            foreach (DataGridViewRow dataRow in dgvEspecialidades.SelectedRows)
            {
                speciality = DataRowViewToViewModel.convertSpecialityViewModel(dataRow);
            }

            return(speciality);
        }
Exemple #7
0
        private void editarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SpecialityViewModel speciality = getViewModelfromRowData();

            Frm_DetailSpeciality frm_Details = new Frm_DetailSpeciality();

            frm_Details.specialityViewModel = speciality;
            frm_Details.frmmFather          = this;
            frm_Details.isEditable          = true;
            frm_Details.Show();
        }
Exemple #8
0
        public async Task <ActionResult> CreateSpeciality(SpecialityViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            IBLL.IDepart_SpeManager Manager = new Depart_SpeManager();
            await Manager.AddSpeciality(model.SpecialityId, model.SpecialityName, model.DepartmentId);

            return(Content("添加成功"));
        }
Exemple #9
0
        public ActionResult Create(SpecialityViewModel specialityvm)
        {
            if (!ModelState.IsValid)
            {
                return(View(specialityvm));
            }
            var speciality = _mapper.Map <SpecialityViewModel, Speciality>(specialityvm);

            _specialityService.Create(speciality);
            _loggerService.Info($"{User.Identity.Name} added speciality{speciality.Name}");
            return(RedirectToAction("Index"));
        }
Exemple #10
0
        public ActionResult Edit(int id)
        {
            var speciality          = _specialityManager.GetById(id);
            var specialityViewModel = new SpecialityViewModel
            {
                Id = speciality.Id,
                NameOfSpeciality = speciality.NameOfSpeciality,
                Department       = _departmentManager.GetById(speciality.DepartmentId).NameOfDepartment
            };

            ViewBag.Departments = _departmentManager.GetAll();
            return(View(specialityViewModel));
        }
Exemple #11
0
        public void InsertSpeciality(SpecialityViewModel specialityVM, Speciality specialityss)
        {
            Speciality spe = new Speciality();

            spe.SpecialityName = specialityVM.SpecialityName;
            spe.InactiveFlag   = "N";
            spe.ModifiedDate   = DateTime.Now;

            //specialityss.InactiveFlag = "N";
            //specialityss.ModifiedDate = DateTime.Now;
            //specialityss.SpecialityName = specialityVM.SpecialityName;

            DBcontext.Specialitys.Add(spe);
        }
Exemple #12
0
 public ActionResult Create(SpecialityViewModel specialityViewModel)
 {
     if (ModelState.IsValid)
     {
         var speciality = new SpecialityDTO
         {
             NameOfSpeciality = specialityViewModel.NameOfSpeciality,
             DepartmentId     = _departmentManager.GetAll().Where(t => t.NameOfDepartment.Equals(specialityViewModel.Department)).ToList().First().Id
         };
         _specialityManager.Create(speciality);
         return(RedirectToAction(nameof(Index)));
     }
     return(View());
 }
Exemple #13
0
 public ActionResult Create(SpecialityViewModel model)
 {
     if (ModelState.IsValid)
     {
         var speciality = AutoMapper.Mapper.Map <Speciality>(model);
         speciality.CreatedOn = DateTime.UtcNow;
         speciality.UpdatedOn = DateTime.UtcNow;
         var isSave = this._specialityservice.SaveSpeciality(speciality);
         if (isSave > 0)
         {
             return(RedirectToAction("Index"));
         }
     }
     return(View(model));
 }
Exemple #14
0
 public ActionResult Edit(SpecialityViewModel model)
 {
     if (ModelState.IsValid)
     {
         Speciality speciality = this._specialityservice.GetSpeciality(model.Id);
         speciality           = AutoMapper.Mapper.Map(model, speciality);
         speciality.UpdatedOn = DateTime.UtcNow;
         var isUpdate = this._specialityservice.UpdateSpeciality(speciality);
         if (isUpdate > 0)
         {
             return(RedirectToAction("Index"));
         }
     }
     return(View(model));
 }
Exemple #15
0
 /// <summary>
 /// To activate or inactivate sprciality
 /// </summary>
 /// <param name="speciality"></param>
 public bool ActiveOrInactiveSpecialities(SpecialityViewModel speciality)
 {
     try
     {
         Speciality sp = new Speciality();
         sp.ID             = speciality.ID;
         sp.SpecialityCode = speciality.SpecialityCode;
         return(_specialityRespository.ActiveOrInactiveSpecialities(sp));
     }
     catch (Exception ex)
     {
         _logger.Log(ex, LogLevel.Error, ex.Message);
         return(false);
     }
 }
        public async Task <ActionResult> SuggestSpeciality(SpecialityViewModel speciality)
        {
            try
            {
                // I. Checks.
                string currentUserId = System.Web.HttpContext.Current.User.Identity.GetUserId();
                if (currentUserId == null)
                {
                    return(new HttpUnauthorizedResult());
                }

                // II. Set ViewBag properties.
                ViewBag.SubjectName = (await SubjectService.GetAsync(speciality.SubjectId)).SubjectName;
                ViewBag.ParentId    = speciality.SubjectId;
                ViewBag.Action      = "SubjectSpecialities";

                // III. Create a new speciality.
                if (ModelState.IsValid)
                {
                    SpecialityDTO specialityDTO = new SpecialityDTO
                    {
                        SubjectId      = speciality.SubjectId,
                        SpecialityName = speciality.Name,
                        Description    = speciality.Description,
                        IsApproved     = false
                    };
                    OperationDetails operationDetails = await SpecialityService.CreateAsync(specialityDTO, currentUserId);

                    if (operationDetails.Succedeed)
                    {
                        return(PartialView("Report", operationDetails));
                    }
                    else
                    {
                        ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
                        return(PartialView("Report", operationDetails));
                    }
                }

                // IV.
                ViewBag.Message = "Non valid";
                return(PartialView(speciality));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #17
0
        private void verDetalleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SpecialityViewModel speciality = new SpecialityViewModel();

            foreach (DataGridViewRow dataRow in dgvEspecialidades.SelectedRows)
            {
                speciality = DataRowViewToViewModel.convertSpecialityViewModel(dataRow);
            }

            Frm_DetailSpeciality frm_Details = new Frm_DetailSpeciality();

            frm_Details.specialityViewModel = speciality;
            frm_Details.frmmFather          = this;
            frm_Details.isEditable          = false;
            frm_Details.Show();
        }
Exemple #18
0
 public ActionResult EditSpeciality(SpecialityViewModel speciality)
 {
     try
     {
         SpecialityDTO specialityDTO = new SpecialityDTO {
             Id = speciality.Id, Name = speciality.Name
         };
         specialityService.ValidateSpeciality2(specialityDTO);
         specialityService.UpdateSpeciality(specialityDTO);
         return(RedirectToRoute(new { Controller = "Admin", Action = "Specialities" }));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError(ex.Property, ex.Message);
     }
     return(View(speciality));
 }
        public async Task <IActionResult> AssignSpeciality(SpecialityViewModel model)
        {
            if (_workContext.WorkingArea.ServiceSupplyIds != null && _workContext.WorkingArea.ServiceSupplyIds.Any())
            {
                if (!_workContext.WorkingArea.ServiceSupplyIds.Contains(model.doctorId))
                {
                    throw new AccessDeniedException();
                }
            }

            var doctor = await _dbContext.ServiceSupplies.FindAsync(model.doctorId);

            if (doctor == null)
            {
                throw new EntityNotFoundException();
            }

            if (doctor.ServiceSupplyInfo == null)
            {
                throw new Exception(Messages.UserIsNotDoctorYouCannotAssignSpeciality);
            }

            var currentExpertises = doctor.DoctorExpertises.Select(x => new
            {
                x.Expertise.Id
            }).Distinct().ToList();

            var founded = (from ce in currentExpertises where ce.Id == model.expertiseId select ce).FirstOrDefault();

            if (founded == null)
            {
                _dbContext.DoctorExpertises.Add(new DoctorExpertise
                {
                    ServiceSupplyId = model.doctorId,
                    ExpertiseId     = model.expertiseId,
                    CreatedAt       = DateTime.Now
                });

                _dbContext.SaveChanges();
            }

            var userMessage = Messages.ActionDoneSuccesfully;

            return(RedirectToAction("Index", "Speciality", new { area = "", model.PolyclinicId, model.doctorId, userMessage }));
        }
Exemple #20
0
        public ActionResult Create(SpecialityViewModel specialityVM)
        {
            //     var cSpeciality = specialityRepository.CheckSpeciality(specialityVM.specialitys.SpecialityName);

            var cSpeciality = db.Specialitys.FirstOrDefault(x => x.SpecialityName == specialityVM.SpecialityName);

            try
            {
                if (ReferenceEquals(cSpeciality, null))
                {
                    if (ModelState.IsValid)
                    {
                        var newSpeciality = new Speciality();
                        if (Session["EditSpeciality"] != null)
                        {
                            newSpeciality.SpecialityID   = Convert.ToInt32(Session["EditSpeciality"]);
                            newSpeciality.SpecialityName = specialityVM.SpecialityName;
                            newSpeciality.InactiveFlag   = "N";
                            newSpeciality.ModifiedDate   = DateTime.Now;
                            specialityRepository.UpdateSpeciality(newSpeciality);
                            Session["EditSpeciality"] = null;
                        }
                        else
                        {
                            specialityRepository.InsertSpeciality(specialityVM, specialityVM.specialityss);
                        }
                        specialityRepository.Save();
                        @TempData["SuccessMessage"] = "Added Successfully....";
                    }
                }
                else
                {
                    //   ModelState.AddModelError("Speciality.SpecialityName", "Speciality Name Already Exist");
                    @TempData["Message"] = "" + specialityVM.SpecialityName + "Speciality Name Already Exist";
                }
            }
            catch (Exception)
            {
                ModelState.AddModelError(string.Empty, "Unable to Add changes. Try again, and if the problem persists contact your system administrator.");
            }
            return(RedirectToAction("Create"));
        }
Exemple #21
0
        public ActionResult Create()
        {
            @TempData["Name"] = Session["Name"];
            SpecialityViewModel _specialityVM = new SpecialityViewModel();

            _specialityVM.SpecialityList = specialityRepository.GetSpecialitys().Where(x => x.InactiveFlag == "N").ToList();

            int editInputs = (Session["EditSpeciality"] != null) ? (Convert.ToInt32(Session["EditSpeciality"])) : 0;

            if (editInputs != 0)
            {
                List <Speciality> _NewSpeciality = specialityRepository.GetSpecialitys().Where(x => x.SpecialityID == editInputs).ToList();

                foreach (var item in _NewSpeciality)
                {
                    _specialityVM.SpecialityName = item.SpecialityName;

                    // Session["EditSpeciality"] = null;
                }
            }

            return(View(_specialityVM));
        }
Exemple #22
0
        public ActionResult Index(string searchString)
        {
            var specialities = new List <SpecialityViewModel>();

            if (String.IsNullOrEmpty(searchString))
            {
                foreach (var speciality in _specialityManager.GetAll())
                {
                    var department          = _departmentManager.GetById(speciality.DepartmentId).NameOfDepartment;
                    var specialityViewModel = new SpecialityViewModel
                    {
                        Id = speciality.Id,
                        NameOfSpeciality = speciality.NameOfSpeciality,
                        Department       = department
                    };
                    specialities.Add(specialityViewModel);
                }
            }
            else
            {
                var departmentId = _departmentManager.GetAll().Where(t => t.NameOfDepartment.Equals(searchString)).ToList()
                                   .First().Id;
                foreach (var speciality in _specialityManager.GetAll().Where(t => t.DepartmentId.Equals(departmentId)).ToList())
                {
                    var specialityViewModel = new SpecialityViewModel
                    {
                        Id = speciality.Id,
                        NameOfSpeciality = speciality.NameOfSpeciality,
                        Department       = _departmentManager.GetById(departmentId).NameOfDepartment
                    };
                    specialities.Add(specialityViewModel);
                }
            }

            return(View(specialities));
        }
        public ActionResult GetSchedulingByDay(DateTime date)
        {
            try
            {
                var schedulings = _schedulingService.GetSchedulings(_ => _.Date.Date.Equals(date.Date) && _.IsAvailable);

                var specialityGroup = schedulings.GroupBy(_ => _.SpecialityId);
                List <SpecialityViewModel> specialitiesVM = new List <SpecialityViewModel>();
                foreach (var data in specialityGroup)
                {
                    var specialityVM = new SpecialityViewModel()
                    {
                        Id   = Guid.Parse(data.Key),
                        Name = data.ToList()[0].SpecialityName
                    };
                    specialitiesVM.Add(specialityVM);
                }
                return(Ok(specialitiesVM));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemple #24
0
 public SpecialityView()
 {
     InitializeComponent();
     BindingContext = new SpecialityViewModel();
 }
Exemple #25
0
 public bool ActiveOrInactiveSpecialities([FromBody] SpecialityViewModel speciality)
 {
     return(_specialityBusiness.ActiveOrInactiveSpecialities(speciality));
 }
Exemple #26
0
        public ActionResult Create()
        {
            var speciality = new SpecialityViewModel();

            return(View(speciality));
        }