public IActionResult DeleteJob([FromBody] DTOJob jobObject) { //_unitOfWork.Jobs.Remove(jobObject); //_unitOfWork.Complete(); DeleteFile(jobObject); return(Ok()); }
private void DeleteFile(DTOJob obj) { JObject jObject = (JObject)JToken.FromObject(obj); string uploadDir = Path.Combine(_webHostEnvironment.ContentRootPath, "Json"); string filePath = Path.Combine(uploadDir, obj.Guid); System.IO.File.Delete(filePath); }
public void AddJob(DTOJob job) { using (SampleDBEntities Entities = new SampleDBEntities()) { var jobEntity = job.ToEntity(); Entities.Jobs.Add(jobEntity); Entities.SaveChanges(); } }
public IActionResult UpdateJob([FromBody] DTOJob jobObject) { //_unitOfWork.Jobs.Update(jobObject); //_unitOfWork.Complete(); DeleteJob(jobObject); CreateJob(jobObject); return(Ok()); }
public static Job ToEntity(this DTOJob dtoJob) { Job entityJob = new Job() { JobNumber = dtoJob.JobNumber, status = dtoJob.status, Path = dtoJob.Path }; return(entityJob); }
/// <summary> /// Method used for Generating Json Files to Store Data /// </summary> /// <param name="obj"></param> private void CreateFile(DTOJob obj) { string uploadDir = Path.Combine(_webHostEnvironment.ContentRootPath, "Json"); var fileName = Guid.NewGuid().ToString() + ".json"; //use the guid for file identification when updating obj.Guid = fileName; JObject jObject = (JObject)JToken.FromObject(obj); string filePath = Path.Combine(uploadDir, fileName); System.IO.File.WriteAllText(filePath, jObject.ToString()); }
public void UpdateJob(DTOJob job) { using (SampleDBEntities Entities = new SampleDBEntities()) { var result = Entities.Jobs.FirstOrDefault(x => x.JobNumber == job.JobNumber); if (result != null) { result.status = job.status; } Entities.SaveChanges(); } }
public IActionResult CreateJob([FromBody] Job jobObject) { var jobMapping = new DTOJob { JobId = jobObject.JobId == -1 ? LongRandom() : jobObject.JobId, JobTitle = jobObject.JobTitle, Description = jobObject.Description, CreatedAt = jobObject.CreatedAt, ExpiresAt = jobObject.ExpiresAt }; CreateFile(jobMapping); //_unitOfWork.Jobs.Add(jobMapping); //_unitOfWork.Complete(); return(Ok()); }
private void InsertIntoJobTracking(DTOJob job) { DTOJobTracking jobTrack = new DTOJobTracking() { JobNumber = job.JobNumber, status = job.status, Path = job.Path }; try { objBL.AddJobTracking(jobTrack); } catch (Exception ex) { Log.LogMessage("Add Job Tracking Failed"); Log.LogMessage(ex.Message); } }
private void UpdateJob(long jobnumber) { DTOJob job = new DTOJob() { JobNumber = jobnumber, status = (int)Status.Moved, Path = destPath }; try { objBL.UpdateJob(job); Log.LogMessage("job Updated....."); InsertIntoJobTracking(job); } catch (Exception ex) { Log.LogMessage("job updation failed"); Log.LogMessage(ex.Message); } }
private long CreateJob(string file) { DTOJob job = new DTOJob() { JobNumber = objBL.GetJobNumber(), status = (int)Status.created, Path = file }; try { objBL.AddJob(job); Log.LogMessage("Job created...."); InsertIntoJobTracking(job); } catch (Exception ex) { Log.LogMessage("job creation failed, Exception"); Log.LogMessage(ex.Message); } return(job.JobNumber); }
public void UpdateJob(DTOJob job) { objDal.UpdateJob(job); }
public void AddJob(DTOJob job) { objDal.AddJob(job); }