public ActionResult WorkRequestAssignment(WorkRequestAssignmentModel objWorkRequestAssignmentModel) { eTracLoginModel objeTracLoginModel = (eTracLoginModel)(Session["eTrac"]); WorkRequestAssignmentModel _objWorkRequestAssignmentModel = new WorkRequestAssignmentModel(); try { if (objWorkRequestAssignmentModel.WorkRequestAssignmentID == 0) { objWorkRequestAssignmentModel.CreatedBy = objeTracLoginModel.UserId; objWorkRequestAssignmentModel.CreatedDate = DateTime.UtcNow; objWorkRequestAssignmentModel.RequestBy = objeTracLoginModel.UserId; objWorkRequestAssignmentModel.WorkRequestStatus = 14; } else { objWorkRequestAssignmentModel.ModifiedBy = objeTracLoginModel.UserId; objWorkRequestAssignmentModel.ModifiedDate = DateTime.UtcNow; } _objWorkRequestAssignmentModel = _IGlobalAdmin.SaveWorkRequestAssignment(objWorkRequestAssignmentModel); if (_objWorkRequestAssignmentModel.Result == Result.Completed) { ViewBag.Message = CommonMessage.SaveSuccessMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Success; } else if (_objWorkRequestAssignmentModel.Result == Result.DuplicateRecord) { ViewBag.Message = CommonMessage.DuplicateRecordMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Info; // store the message for successful in tempdata to display in view. } else if (_objWorkRequestAssignmentModel.Result == Result.UpdatedSuccessfully) { ViewBag.Message = CommonMessage.UpdateSuccessMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;// store the message for successful in tempdata to display in view. } else { ViewBag.Message = CommonMessage.FailureMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;// store the failure message in tempdata to display in view. } return(View("WorkRequestAssignment", _objWorkRequestAssignmentModel)); } catch (Exception) { throw; } finally { ViewBag.AssignToUser = _IGlobalAdmin.GetLocationEmployee(objeTracLoginModel.LocationID); ViewBag.Asset = _ICommonMethod.GetAssetList(objeTracLoginModel.LocationID); ViewBag.Location = _ICommonMethod.GetAllLocation(); ViewBag.PriorityLevel = _ICommonMethod.GetGlobalCodeData("WORKPRIORITY"); ViewBag.WorkRequestType = _ICommonMethod.GetGlobalCodeData("WORKREQUESTTYPE"); ViewBag.WorkRequestProjectTypeID = _ICommonMethod.GetGlobalCodeData("WORKREQUESTPROJECTTYPE"); } }
/// <summary>Save DAR for Jump Start /// <CreatedFor>For Insert Jump Start and GT Tracker</CreatedFor> /// <CreatedBy>Bhushan Dod</CreatedBy> /// <CreatedOn>March-16-2015</CreatedOn> /// </summary> /// <param name="objServiceDARModel"></param> /// <returns></returns> public ServiceDARModel SaveDARDetailsForTracking(ServiceDARModel obj) { ObjUserRepository = new UserRepository(); objDARRepository = new DARRepository(); try { if (obj.LocationId > 0 && obj.ServiceAuthKey != null) { var authuser = ObjUserRepository.GetSingleOrDefault(x => x.ServiceAuthKey == obj.ServiceAuthKey && x.IsDeleted == false); if (authuser != null && authuser.UserId > 0) { //THIS SECTION FOR ACCEPTING THE FACILITY REQUEST if (obj.FacilityRequest == true) { objWorkRequestAssignmentRepository = new WorkRequestAssignmentRepository(); objWork = new WorkRequestAssignmentModel(); var workDetails = objWorkRequestAssignmentRepository.GetSingleOrDefault(t => t.WorkRequestAssignmentID == obj.WorkAssignmentID && t.LocationID == obj.LocationId && t.IsDeleted == false); if (workDetails != null && (workDetails.AssignToUserId == null || workDetails.AssignToUserId == 0) && workDetails.StartTime == null) { workDetails.AssignToUserId = obj.UserId; workDetails.AssignByUserId = obj.UserId; workDetails.StartTime = DateTime.UtcNow; workDetails.ModifiedBy = obj.UserId; workDetails.ModifiedDate = DateTime.UtcNow; workDetails.WorkRequestStatus = 15; objWorkRequestAssignmentRepository.SaveChanges(); obj.ActivityDetails = DarMessage.FacilityRequestAccept(obj.UserName, obj.LocationName); obj.StartTime = DateTime.UtcNow.ToString(); var result = objDARRepository.InsertDARDetailsForTracking(obj); if (result != null && result > 0) { // obj = null; obj.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.SaveSuccessMessage(); } else { obj.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.WrongParameterMessage(); } } else { obj.Response = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.CurrentCulture); obj.ResponseMessage = CommonMessage.AlreadyAcceptedFacilityRequest(); } } //THIS SECTION FOR DAR ENTRY FOR CUSTOMER CALL if (obj.FacilityRequest == false && obj.StartTime != null && obj.EndTime != null && obj.TaskType == (long)DARTASKTYPECATEGORY.CustomerCall) { if (obj.StartTime != null) { obj.StartTime = DateTime.UtcNow.ToString(); } if (obj.EndTime != null) { obj.EndTime = DateTime.UtcNow.ToString(); } obj.ActivityDetails = DarMessage.DarCustomerCall(obj.UserName, obj.LocationName, obj.Description); var result = objDARRepository.InsertDARDetailsForTracking(obj); if (result != null && result > 0) { // obj = null; obj.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.SaveSuccessMessage(); } else { obj.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.WrongParameterMessage(); } } //THIS SECTION FOR DAR ENTRY JUMP START AND END TIME if (obj.FacilityRequest == false && obj.StartTime != null && obj.TaskType == (long)DARTASKTYPECATEGORY.DARType) { if (obj.StartTime != null) { obj.StartTime = DateTime.UtcNow.ToString(); } obj.ActivityDetails = DarMessage.DarJumpStartEndTimeStatus(obj.UserName, obj.LocationName, obj.Description); var result = objDARRepository.InsertDARDetailsForTracking(obj); if (result != null && result > 0) { // obj = null; obj.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.SaveSuccessMessage(); } else { obj.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.WrongParameterMessage(); } } //THIS SECTION FOR DAR ENTRY FOR 18 TO 33 CODE if (obj.FacilityRequest == false && obj.StartTime != null && obj.TaskType == (int)DARTASKTYPECATEGORY.GateRepair || obj.TaskType == (int)DARTASKTYPECATEGORY.CustomerVehicleLocate || obj.TaskType == (int)DARTASKTYPECATEGORY.CustomerJumpStart || obj.TaskType == (int)DARTASKTYPECATEGORY.Customertireinflation || obj.TaskType == (int)DARTASKTYPECATEGORY.CustomerAssistance || obj.TaskType == (int)DARTASKTYPECATEGORY.WorkBreak || obj.TaskType == (int)DARTASKTYPECATEGORY.SpecialProject || obj.TaskType == (int)DARTASKTYPECATEGORY.RoutineChecks || obj.TaskType == (int)DARTASKTYPECATEGORY.SpaceCount || obj.TaskType == (int)DARTASKTYPECATEGORY.LicensePlateInventory || obj.TaskType == (int)DARTASKTYPECATEGORY.Emergency || obj.TaskType == (int)DARTASKTYPECATEGORY.Facilitycleaning || obj.TaskType == (int)DARTASKTYPECATEGORY.FacilitySpillResponse || obj.TaskType == (int)DARTASKTYPECATEGORY.SnowRemoval || obj.TaskType == (int)DARTASKTYPECATEGORY.TicketSpitterRepair || obj.TaskType == (int)DARTASKTYPECATEGORY.MiscellaneousEvent) { if (obj.StartTime != null) { obj.StartTime = DateTime.UtcNow.ToString(); } //obj.ActivityDetails = DarMessage.DarJumpStartEndTimeStatus(obj.UserName, obj.LocationName, obj.Description); var result = objDARRepository.InsertDARDetailsForTracking(obj); if (result != null && result > 0) { // obj = null; obj.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.SaveSuccessMessage(); } else { obj.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.WrongParameterMessage(); } } //THIS SECTION FOR EMPLOYEE STARTED CR FOR THE DAY AND IF STARTDATE = workDetails.StartDate then update WorkRequestStatus if (obj.FacilityRequest == false && obj.StartTime != null && obj.EndTime == null && obj.TaskType == (long)DARTASKTYPECATEGORY.ContinuousRequestEnd) { if (obj.StartTime != null) { obj.StartTime = DateTime.UtcNow.ToString(); } objWorkRequestAssignmentRepository = new WorkRequestAssignmentRepository(); objWork = new WorkRequestAssignmentModel(); var workDetails = objWorkRequestAssignmentRepository.GetSingleOrDefault(t => t.WorkRequestAssignmentID == obj.WorkAssignmentID && t.LocationID == obj.LocationId && t.IsDeleted == false); if (workDetails != null && workDetails.StartDate != null) { //Not sure about DateTimeNow bcoz if in future change UTC then StartDate save according to UTC if (DateTime.UtcNow.ToShortDateString() == workDetails.StartDate.Value.ToShortDateString()) { workDetails.WorkRequestStatus = 15; workDetails.StartTime = DateTime.UtcNow; workDetails.ModifiedBy = obj.UserId; workDetails.ModifiedDate = DateTime.UtcNow;; objWorkRequestAssignmentRepository.SaveChanges(); } obj.ActivityDetails = DarMessage.CRTaskStart(obj.UserName, obj.LocationName); var result = objDARRepository.InsertDARDetailsForTracking(obj); if (result != null && result > 0) { // obj = null; obj.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.SaveSuccessMessage(); } else { obj.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.WrongParameterMessage(); } } else { obj.Response = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.CurrentCulture); obj.ResponseMessage = CommonMessage.AlreadyAcceptedFacilityRequest(); } } //THIS SECTION FOR EMPLOYEE ENDED CR FOR THE DAY AND IF ENDDATE = workDetails.EndDate then update WorkRequestStatus if (obj.FacilityRequest == false && obj.EndTime != null && obj.TaskType == (long)DARTASKTYPECATEGORY.ContinuousRequestEnd) { if (obj.EndTime != null) { obj.EndTime = DateTime.UtcNow.ToString(); } objWorkRequestAssignmentRepository = new WorkRequestAssignmentRepository(); objWork = new WorkRequestAssignmentModel(); var workDetails = objWorkRequestAssignmentRepository.GetSingleOrDefault(t => t.WorkRequestAssignmentID == obj.WorkAssignmentID && t.LocationID == obj.LocationId && t.IsDeleted == false); if (workDetails != null && workDetails.EndDate != null) { //Not sure about DateTimeNow bcoz if in future change UTC then StartDate save according to UTC if (DateTime.UtcNow.ToShortDateString() == workDetails.EndDate.Value.ToShortDateString()) { workDetails.WorkRequestStatus = 16; workDetails.EndTime = DateTime.UtcNow; workDetails.ModifiedBy = obj.UserId; workDetails.ModifiedDate = DateTime.UtcNow;; objWorkRequestAssignmentRepository.SaveChanges(); } obj.ActivityDetails = DarMessage.CRTaskEnd(obj.UserName, obj.LocationName); var result = objDARRepository.InsertDARDetailsForTracking(obj); if (result != null && result > 0) { // obj = null; obj.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.SaveSuccessMessage(); } else { obj.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture); obj.DARId = result; obj.ResponseMessage = CommonMessage.WrongParameterMessage(); } } else { obj.Response = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.CurrentCulture); obj.ResponseMessage = CommonMessage.AlreadyAcceptedFacilityRequest(); } } } else { obj.Response = Convert.ToInt32(ServiceResponse.InvalidSessionResponse, CultureInfo.CurrentCulture); obj.ResponseMessage = CommonMessage.InvalidUser(); } } else { obj.Response = Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture); obj.ResponseMessage = CommonMessage.WrongParameterMessage(); } } catch (Exception) { throw; } return(obj); }