// GET: CalendarDate/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            M_CalendarDate editableDate = _repositoriyCalendar.FindById(id.Value);

            if (editableDate == null)
            {
                return(HttpNotFound());
            }

            CalendarDateViewModel editableDateVM = new CalendarDateViewModel(editableDate);
            var list = ViewModelFactory.GetSelectedListEmployersName(_employers);

            if (list.Count() != 0)
            {
                list.Where(li => li.Value == editableDateVM.NameEmployer)
                .FirstOrDefault()
                .Selected = true;
            }

            ViewBag.EmployerNames = list;
            return(View(editableDateVM));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            M_CalendarDate deletedDate = _repositoriyCalendar.FindById(id);

            _repositoriyCalendar.Remove(deletedDate);
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(CalendarDateViewModel createdDate)
        {
            if (ModelState.IsValid)
            {
                M_CalendarDate m_CalendarDate = createdDate.GetModel() as M_CalendarDate;
                _repositoriyCalendar.Create(m_CalendarDate);
                return(RedirectToAction("Index"));
            }

            return(View(createdDate));
        }
        public ActionResult Edit(CalendarDateViewModel editableDateVM)
        {
            M_CalendarDate editableDate = editableDateVM.GetModel() as M_CalendarDate;

            if (ModelState.IsValid)
            {
                _repositoriyCalendar.Update(editableDate);
                return(RedirectToAction("Index"));
            }

            return(View(editableDateVM));
        }
        public override void SetModel(M_Base modelBase)
        {
            M_CalendarDate modelEntity = modelBase as M_CalendarDate;

            _model       = modelEntity;
            Id           = modelEntity.Id;
            Start        = modelEntity.Start;
            End          = modelEntity.End;
            NameEmployer = GetName(modelEntity.Employee?.PersonInfo);
            TypeDate     = modelEntity.TypeDate;
            _employer    = modelEntity?.Employee;
        }
        // GET: CalendarDate/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            M_CalendarDate deletedDate = _repositoriyCalendar.FindById(id.Value);

            if (deletedDate == null)
            {
                return(HttpNotFound());
            }

            CalendarDateViewModel deletedDateVM = new CalendarDateViewModel(deletedDate);

            return(View(deletedDateVM));
        }
        // GET: CalendarDate/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            M_CalendarDate m_CalendarDate = _repositoriyCalendar.FindById(id.Value);


            if (m_CalendarDate == null)
            {
                return(HttpNotFound());
            }

            CalendarDateViewModel calendarDetails = new CalendarDateViewModel(m_CalendarDate);

            return(View(calendarDetails));
        }
 public CalendarDateViewModel(M_CalendarDate model) : base(model)
 {
 }