Beispiel #1
0
        public ActionResult CreateRequestForOther([Bind(Include = "Id,FromPlace,DestinationPlace,StartDateTime,StartTime,EndDateTime,EndTime,PassengerQty,Description,RequestFor")] RequisitonForAnotherViewModel requisitonForAnother)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var      startDate     = requisitonForAnother.StartDateTime.ToString("MM/dd/yyyy");
                    var      startTime     = requisitonForAnother.StartTime;
                    DateTime startDateTime = Convert.ToDateTime(startDate + " " + startTime);
                    requisitonForAnother.StartDateTime = startDateTime;

                    var      endDate     = requisitonForAnother.EndDateTime.ToString("MM/dd/yyyy");
                    var      endTime     = requisitonForAnother.EndTime;
                    DateTime endDateTime = Convert.ToDateTime(endDate + " " + endTime);
                    requisitonForAnother.EndDateTime = endDateTime;

                    requisitonForAnother.RequisitionNumber = requisitonForAnother.GetRequisitionNumber();

                    //Get employee Id by user login id
                    var loginUserId = Convert.ToInt32(User.Identity.GetUserId());
                    var empId       = _employeeManager.FindByLoginId(loginUserId);
                    requisitonForAnother.EmployeeId = empId.Id;

                    Requisition requisition = Mapper.Map <Requisition>(requisitonForAnother);
                    requisition.SubmitDateTime = DateTime.Now;

                    bool isSaved = _requisitionManager.Add(requisition);
                    //Requisition Status Save
                    if (isSaved)
                    {
                        RequisitionStatus status = new RequisitionStatus();
                        status.RequisitionNumber = requisition.RequisitionNumber;

                        status.RequisitionId = requisition.Id;
                        status.StatusType    = "New";
                        _requisitionStatusManager.Add(status);

                        // Notification Status Save
                        Notification notification = new Notification();
                        notification.Text                 = "Request for a vehicle";
                        notification.EmployeeId           = empId.Id;
                        notification.ControllerViewStatus = "Unseen";
                        notification.RequisitionId        = requisition.Id;
                        notification.NotifyDateTime       = DateTime.Now;
                        _notificationManager.Add(notification);

                        TempData["msg"] = "Requisition has been Send successfully....! Please Wait For Response..........Thanks";
                        return(RedirectToAction("Create"));
                    }
                }

                ViewBag.EmployeeId = new SelectList(_employeeManager.GetAllEmployees(), "Id", "FullName", requisitonForAnother.EmployeeId);
                return(View(requisitonForAnother));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Requisitions", "CreateRequestForOther")));
            }
        }
Beispiel #2
0
        public ActionResult CreateRequestForOther([Bind(Include = "Id,FromPlace,DestinationPlace,StartDateTime,StartTime,EndDateTime,EndTime,Description,RequestFor,EmployeeId")] RequisitonForAnotherViewModel requisitonForAnother)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var      startDate     = requisitonForAnother.StartDateTime.ToString("MM/dd/yyyy");
                    var      startTime     = requisitonForAnother.StartTime;
                    DateTime startDateTime = Convert.ToDateTime(startDate + " " + startTime);
                    requisitonForAnother.StartDateTime = startDateTime;

                    var      endDate     = requisitonForAnother.EndDateTime.ToString("MM/dd/yyyy");
                    var      endTime     = requisitonForAnother.EndTime;
                    DateTime endDateTime = Convert.ToDateTime(endDate + " " + endTime);
                    requisitonForAnother.EndDateTime = endDateTime;

                    requisitonForAnother.RequisitionNumber = requisitonForAnother.GetRequisitionNumber();
                    Requisition requisition = Mapper.Map <Requisition>(requisitonForAnother);

                    bool isSaved = _requisitionManager.Add(requisition);
                    //Requisition Status Save
                    if (isSaved == true)
                    {
                        RequisitionStatus status = new RequisitionStatus();
                        status.RequisitionNumber = requisition.RequisitionNumber;

                        status.RequisitionId = requisition.Id;
                        status.StatusType    = "New";
                        _requisitionStatusManager.Add(status);
                        TempData["msg"] = "Requisition has been Send successfully....! Please Wait For Response..........Thanks";
                        return(RedirectToAction("Index"));
                    }
                }

                ViewBag.EmployeeId = new SelectList(_employeeManager.GetAllEmployees(), "Id", "FullName", requisitonForAnother.EmployeeId);
                return(View(requisitonForAnother));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Requisitions", "CreateRequestForOther")));
            }
        }