public int InsertJobAssigned(JobAssigned _JobAssigned) { //context.JobAssigneds.Add(_JobAssigned); SqlParameter[] Param = new SqlParameter[9]; Param[0] = new SqlParameter("@pJobAssignGUID", SqlDbType.UniqueIdentifier); Param[0].Value = _JobAssigned.JobAssignGUID; Param[1] = new SqlParameter("@pJobGUID", SqlDbType.UniqueIdentifier); Param[1].Value = (object)_JobAssigned.JobGUID ?? DBNull.Value; Param[2] = new SqlParameter("@pUserGUID", SqlDbType.UniqueIdentifier); Param[2].Value = (object)_JobAssigned.UserGUID ?? DBNull.Value; Param[3] = new SqlParameter("@pStartTime", SqlDbType.DateTime); Param[3].Value = (object)_JobAssigned.StartTime ?? DBNull.Value; Param[4] = new SqlParameter("@pEndTime", SqlDbType.DateTime); Param[4].Value = (object)_JobAssigned.EndTime ?? DBNull.Value; Param[5] = new SqlParameter("@pLatitude", SqlDbType.Float); Param[5].Value = (object)_JobAssigned.Latitude ?? DBNull.Value; Param[6] = new SqlParameter("@pLongitude", SqlDbType.Float); Param[6].Value = (object)_JobAssigned.Longitude ?? DBNull.Value; Param[7] = new SqlParameter("@pLastModifiedDate", SqlDbType.DateTime); Param[7].Value = (object)_JobAssigned.LastModifiedDate ?? DBNull.Value; Param[8] = new SqlParameter("@pLastModifiedBy", SqlDbType.UniqueIdentifier); Param[8].Value = (object)_JobAssigned.LastModifiedBy ?? DBNull.Value; return context.Database.ExecuteSqlCommand("insert into JobAssigned(JobAssignGUID,JobGUID,UserGUID,StartTime,EndTime,Latitude,Longitude,LastModifiedDate,LastModifiedBy)" + "values(@pJobAssignGUID,@pJobGUID,@pUserGUID,@pStartTime,@pEndTime,@pLatitude,@pLongitude,@pLastModifiedDate,@pLastModifiedBy)", Param); }
public ActionResult AssignUser(string id = "", string jobindexguid = "") { Logger.Debug("Inside Job Controller- Index"); try { if (Session["OrganizationGUID"] != null) { if (!string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(jobindexguid)) { Job _job = new Job(); _job.JobGUID = new Guid(jobindexguid); _job.AssignedUserGUID = new Guid(id); _job.LastModifiedDate = DateTime.UtcNow; _job.LastModifiedBy = new Guid(Session["UserGUID"].ToString()); int result = _IJobRepository.AssignJob(_job); if (result > 0) { Job job = _IJobRepository.GetJobByID(_job.JobGUID); if (job != null) { JobAssigned _jobAssigned = new JobAssigned(); _jobAssigned.JobAssignGUID = Guid.NewGuid(); _jobAssigned.JobGUID = job.JobGUID; _jobAssigned.UserGUID = job.AssignedUserGUID; _jobAssigned.StartTime = job.ScheduledEndTime; _jobAssigned.EndTime = job.ScheduledEndTime; _jobAssigned.Latitude = job.Latitude; _jobAssigned.Longitude = job.Longitude; _jobAssigned.LastModifiedDate = DateTime.UtcNow; _jobAssigned.LastModifiedBy = new Guid(Session["UserGUID"].ToString()); _IJobRepository.InsertJobAssigned(_jobAssigned); //_IJobRepository.Save(); } } // _IJobRepository.AssignUser(new Guid(id), new Guid(jobindexguid)); } return RedirectToAction("Index", "JobStatus"); } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return RedirectToAction("../User/Login"); } }