Exemple #1
0
        public JsonResult JsonCreate(RequsitionCreateViewModel requisitionVm)
        {
            //newDateTime = date.Date + time.TimeOfDay;

            if (ModelState.IsValid)
            {
                var journeyStart = requisitionVm.JourneyStartDate.Date + requisitionVm.JourneyStartTime.TimeOfDay;
                var jouneyEnd    = requisitionVm.JouneyEndDate.Date + requisitionVm.JouneyEndTime.TimeOfDay;

                Requsition requisition = new Requsition();
                requisition.Form             = requisitionVm.Form;
                requisition.To               = requisitionVm.To;
                requisition.RequsitionNumber = AutoNumber();
                requisition.Description      = requisitionVm.Description;
                requisition.JourneyStart     = journeyStart;
                requisition.JouneyEnd        = jouneyEnd;
                requisition.EmployeeId       = requisitionVm.EmployeeId;

                bool isSaved = _requisitionManager.Add(requisition);
                if (isSaved)
                {
                    TempData["msg"] = "Requisition Send Successfully";
                }
                else
                {
                    TempData["msg"] = "Requisition not Send !";
                }
            }
            else
            {
                TempData["msg"] = "Requisition not Send !";
            }
            return(Json(TempData["msg"], JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(RequsitionViewModel requsitionVM)
        {
            try
            {
                Requsition requsition = new Requsition();
                requsition.Form               = requsitionVM.Form;
                requsition.To                 = requsitionVM.To;
                requsition.Description        = requsitionVM.Description;
                requsition.JourneyStart       = requsitionVM.JourneyStart;
                requsition.JouneyEnd          = requsitionVM.JouneyEnd;
                requsition.EmployeeId         = requsitionVM.EmployeeId;
                requsition.RequsitionStatusId = requsitionVM.RequsitionStatusId;

                bool isSaved = _requsitionManager.Add(requsition);
                if (isSaved)
                {
                    TempData["msg"] = "Requsition Send Successfully";
                }
                return(RedirectToAction("Create"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult MyJsonCreate(MyRequsitionCreateViewModel requisitionVm)
        {
            //newDateTime = date.Date + time.TimeOfDay;
            //TempData["msg"] = null;
            ViewBag.Message = null;
            List <MyRequsitionListViewModel> requsitionViewList;

            if (ModelState.IsValid)
            {
                int requestForEmployeeId;
                if (requisitionVm.RequestForOther == false)
                {
                    requestForEmployeeId = GetEmployeeId();
                }
                else
                {
                    requestForEmployeeId = (int)requisitionVm.EmployeeId;
                }
                DateTime journyStartDate = (DateTime)requisitionVm.JourneyStartDate;

                var      journeyStart  = journyStartDate.Date + requisitionVm.JourneyStartTime.TimeOfDay;
                DateTime jouneyEndDate = (DateTime)requisitionVm.JouneyEndDate;
                var      jouneyEnd     = jouneyEndDate.Date + requisitionVm.JouneyEndTime.TimeOfDay;



                Requsition requisition = new Requsition();
                requisition.Form             = requisitionVm.Form;
                requisition.To               = requisitionVm.To;
                requisition.RequsitionNumber = AutoNumber();
                requisition.Description      = requisitionVm.Description;
                requisition.JourneyStart     = journeyStart;
                requisition.JouneyEnd        = jouneyEnd;
                requisition.EmployeeId       = requestForEmployeeId;

                requisition.RequestedBy = GetEmployeeId();
                requisition.RequestType = requisitionVm.RequestType;

                bool isSaved = _requisitionManager.Add(requisition);
                if (isSaved)
                {
                    //TempData["msg"] = "Requisition Send Successfully";
                    ViewBag.Message = "Requisition Send Successfully";
                }
                else
                {
                    //TempData["msg"] = "Requisition not Send !";
                    ViewBag.Message = "Requisition not Send !";
                }

                requsitionViewList = MyRequisitionListView();
                return(PartialView("_MyRequisitionListPartial", requsitionViewList));
            }
            //TempData["msg"] = "Requisition not Send !";
            ViewBag.Message    = "Requisition not Send !";
            requsitionViewList = MyRequisitionListView();
            return(PartialView("_MyRequisitionListPartial", requsitionViewList));
        }