Exemplo n.º 1
0
        public ActionResult MissionOrderEdit(MissionOrderEditModel model)
        {
            CorrectCheckboxes(model);
            CorrectDropdowns(model);
            if (!ValidateMissionOrderEditModel(model))
            {
                //model.IsApproved = false;
                //model.IsApprovedForAll = false;
                RequestBl.ReloadDictionaries(model);
                return View(model);
            }

            string error;
            if (!RequestBl.SaveMissionOrderEditModel(model, out error))
            {
                if (model.ReloadPage)
                {
                    ModelState.Clear();
                    if (!string.IsNullOrEmpty(error))
                        ModelState.AddModelError("", error);
                    return View(RequestBl.GetMissionOrderEditModel(model.Id, model.UserId));
                }
                if (!string.IsNullOrEmpty(error))
                    ModelState.AddModelError("", error);
            }
            if (!string.IsNullOrEmpty(error))
                return View(model);
            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
 protected void CorrectDropdowns(MissionOrderEditModel model)
 {
     if (!model.IsEditable)
      {
          model.TypeId = model.TypeIdHidden;
          model.Kind = model.KindHidden;
          model.GoalId = model.GoalIdHidden;
      }
      if(!model.IsSecritaryEditable)
      {
          model.AirTicketType = model.AirTicketTypeHidden;
          model.TrainTicketType = model.TrainTicketTypeHidden;
      }
 }
Exemplo n.º 3
0
 protected bool ValidateMissionOrderEditModel(MissionOrderEditModel model)
 {
     if (model.IsTicketsEditable) return true;
     //return false;
     if (string.IsNullOrEmpty(model.BeginMissionDate) || string.IsNullOrEmpty(model.EndMissionDate))
         ModelState.AddModelError("BeginMissionDate", StrNoBeginOrEndDate);
     if(RequestBl.CheckAnyOtherOrdersExists(model))
         ModelState.AddModelError("BeginMissionDate", StrOtherOrdersExists);
     /*if (RequestBl.CheckOtherOrdersExists(model))
         ModelState.AddModelError("BeginMissionDate", StrOtherOrdersExists);*/
     if (!(RequestBl.CheckOrderBeginDate(model.BeginMissionDate) || model.IsTicketsEditable))
         ModelState.AddModelError("BeginMissionDate", StrOrderIsInPast);
     if(!string.IsNullOrEmpty(model.BeginMissionDate) && !string.IsNullOrEmpty(model.EndMissionDate)
         && model.IsEditable)
     {
         //Отключаем члена правления > добавил false &&
         if (false && RequestBl.IsMissionOrderLong(DateTime.Parse(model.EndMissionDate)
             ,DateTime.Parse(model.BeginMissionDate)))
         {
             if(string.IsNullOrEmpty(model.LongTermReason))
                 ModelState.AddModelError("LongTermReason", StrLongTermReasonIsRequired);
             model.IsChiefApproveNeed = true;
             model.IsChiefApproveNeedHidden = true;
         }
         else
         {
             if (ModelState.ContainsKey("LongTermReason"))
                 ModelState.Remove("LongTermReason");
             model.LongTermReason = string.Empty;
             model.IsChiefApproveNeed = false;
             model.IsChiefApproveNeedHidden = false;
         }
     }
     return ModelState.IsValid;
 }
Exemplo n.º 4
0
        protected void CorrectCheckboxes(MissionOrderEditModel model)
        {
            if (!model.IsChiefApproveAvailable /*&& model.IsChiefApprovedHidden.Value*/)
            {
                if (ModelState.ContainsKey("IsChiefApproved"))
                    ModelState.Remove("IsChiefApproved");
                model.IsChiefApproved = model.IsChiefApprovedHidden;
            }
            if (!model.IsManagerApproveAvailable /*&& model.IsManagerApprovedHidden.Value*/)
            {
                if (ModelState.ContainsKey("IsManagerApproved"))
                    ModelState.Remove("IsManagerApproved");
                model.IsManagerApproved = model.IsManagerApprovedHidden;
            }
            if (!model.IsUserApprovedAvailable && model.IsUserApprovedHidden)
            {
                if (ModelState.ContainsKey("IsUserApproved"))
                    ModelState.Remove("IsUserApproved");
                model.IsUserApproved = model.IsUserApprovedHidden;
            }
            if (ModelState.ContainsKey("IsChiefApproveNeed"))
                ModelState.Remove("IsChiefApproveNeed");
            model.IsChiefApproveNeed = model.IsChiefApproveNeedHidden;

            if (model.IsManagerApproveAvailable && model.IsManagerApproved.HasValue
                && !model.IsManagerApproved.Value)
            {
                if (ModelState.ContainsKey("IsManagerApproved"))
                    ModelState.Remove("IsManagerApproved");
            }
            if (model.IsChiefApproveAvailable && model.IsChiefApproved.HasValue
                && !model.IsChiefApproved.Value)
            {
                if (ModelState.ContainsKey("IsChiefApproved"))
                    ModelState.Remove("IsChiefApproved");
                if (ModelState.ContainsKey("IsManagerApproved"))
                    ModelState.Remove("IsManagerApproved");
            }
            if (!model.IsEditable)
            {
                if (model.IsResidencePaidHidden)
                {
                    if (ModelState.ContainsKey("IsResidencePaid"))
                        ModelState.Remove("IsResidencePaid");
                    model.IsResidencePaid = model.IsResidencePaidHidden;
                }
                if (model.IsAirTicketsPaidHidden)
                {
                    if (ModelState.ContainsKey("IsAirTicketsPaid"))
                        ModelState.Remove("IsAirTicketsPaid");
                    model.IsAirTicketsPaid = model.IsAirTicketsPaidHidden;
                }
                if (model.IsTrainTicketsPaidHidden)
                {
                    if (ModelState.ContainsKey("IsTrainTicketsPaid"))
                        ModelState.Remove("IsTrainTicketsPaid");
                    model.IsTrainTicketsPaid = model.IsTrainTicketsPaidHidden;
                }
            }
        }