/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(MSTCustomerDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var cus = context.MST_Customer.Single(x => x.Id == entity.Id && x.IsDeleted == false); cus.CustomerName = entity.CustomerName; cus.EndCustomer = entity.EndCustomer; cus.Location = entity.Location; cus.Strategic = entity.Strategic; cus.IsDeleted = entity.IsDeleted; cus.LastUpdatedBy = entity.LastUpdatedBy; cus.LastUpdate = DateTime.Now; context.Entry<MST_Customer>(cus).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the range asynchronous. /// </summary> /// <param name="entities">The entities.</param> /// <returns></returns> public async Task<SaveResult> AddRangeAsync(IEnumerable<FARInitialTargetLogDto> entities) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { LOG_FARInitialTarget add = null; foreach (var entity in entities) { add = context.LOG_FARInitialTarget.Create(); add.TargetDate = entity.TargetDate; add.ReasonId = entity.ReasonId; add.IsDeleted = false; add.MasterId = entity.MasterId; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<LOG_FARInitialTarget>(add).State = System.Data.Entity.EntityState.Added; } result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the range asynchronous. /// </summary> /// <param name="entities">The entities.</param> /// <returns></returns> public async Task<SaveResult> AddRangeAsync(IEnumerable<MSTServiceDto> entities) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { MST_Services add = null; foreach (var entity in entities) { add = context.MST_Services.Create(); add.Description = entity.Description; add.IsDeleted = false; add.Name = entity.Name; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<MST_Services>(add).State = System.Data.Entity.EntityState.Added; } result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Deletes the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> DeleteAsync(FARUploadDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var assembly = context.LOG_FARUpload.Single(x => x.Id == entity.Id); context.Entry<LOG_FARUpload>(assembly).State = System.Data.Entity.EntityState.Deleted; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(DelayReasonDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { MST_ReasonINIReport add = context.MST_ReasonINIReport.Create(); add.Description = entity.Description; add.IsDeleted = entity.IsDeleted; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<MST_ReasonINIReport>(add).State = System.Data.Entity.EntityState.Added; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the range asynchronous. /// </summary> /// <param name="entities">The entities.</param> /// <returns></returns> public async Task<SaveResult> AddRangeAsync(IEnumerable<RecordLockDto> entities) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { foreach (var entity in entities) { FAR_RecordLock add = context.FAR_RecordLock.Create(); add.ProcessHistoryId = entity.ProcessHistoryId; add.LockBy = entity.LockBy; add.LockDate = entity.LockDate; add.MasterId = entity.MasterId; add.ReleaseDate = entity.ReleaseDate; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<FAR_RecordLock>(add).State = System.Data.Entity.EntityState.Added; } result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(FARUploadDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var upload = context.LOG_FARUpload.Single(x => x.Id == entity.Id); upload.FileName = entity.FileName; upload.MasterId = entity.MasterId; upload.ReasonId = entity.ReasonId; upload.FAType = entity.FAType; upload.UploadedBy = entity.UploadedBy; upload.UploadedDate = DateTime.Now; context.Entry<LOG_FARUpload>(upload).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the range asynchronous. /// </summary> /// <param name="entities">The entities.</param> /// <returns></returns> public async Task<SaveResult> AddRangeAsync(IEnumerable<FARMasterDto> entities) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { FAR_Master add = null; foreach (var entity in entities) { add = context.FAR_Master.Create(); add.Number = entity.Number; add.OriginId = entity.OriginId; add.Requestor = entity.Requestor; add.RefNo = entity.RefNo; add.FailureTypeId = entity.FailureTypeId; add.FailureOriginId = entity.FailureOriginId; add.FailureRate = entity.FailureRate; add.StatusId = entity.StatusId; add.Analyst = entity.Analyst; add.RequestDate = entity.RequestDate; add.SamplesArriveDate = entity.SamplesArriveDate; add.PriorityId = entity.PriorityId; add.InitialReportTargetDate = entity.InitialReportTargetDate; add.BUId = entity.BUId; add.Product = entity.Product; add.FailureDesc = entity.FailureDesc; add.FinalReportTargetDate = entity.FinalReportTargetDate; add.Submitted = entity.Submitted; add.Customer = entity.Customer; add.LabSiteId = entity.LabSiteId; add.RatingId = entity.RatingId; add.Comments = entity.Comments; add.IsDeleted = entity.IsDeleted; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<FAR_Master>(add).State = System.Data.Entity.EntityState.Added; } result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the range asynchronous. /// </summary> /// <param name="entities">The entities.</param> /// <returns></returns> public async Task<SaveResult> AddRangeAsync(IEnumerable<MSTFarReportDto> entities) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { foreach (var entity in entities) { MST_FARReport add = context.MST_FARReport.Create(); add.OriginId = entity.OriginId; add.ReportTypeId = entity.ReportTypeId; add.Required = entity.Required; add.Description = entity.Description; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<MST_FARReport>(add).State = System.Data.Entity.EntityState.Added; } result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(LOGHistoryDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var assembly = context.LOG_FARHistory.Single(x => x.Id == entity.Id && x.IsDeleted == false); assembly.Id = entity.Id; assembly.MasterId = entity.MasterId; assembly.StatusId = entity.StatusId; assembly.ReasonId = entity.ReasonId; assembly.LogDate = entity.LogDate; assembly.IsDeleted = entity.IsDeleted; assembly.ReasonId = entity.ReasonId; assembly.LastUpdatedBy = entity.LastUpdatedBy; assembly.LastUpdate = DateTime.Now; context.Entry<LOG_FARHistory>(assembly).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(FARMasterDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var entry = context.FAR_Master.Single(x => x.Id == entity.Id && x.IsDeleted == false); entry.Number = entity.Number; entry.OriginId = entity.OriginId; entry.Requestor = entity.Requestor; entry.RefNo = entity.RefNo; entry.FailureTypeId = entity.FailureTypeId; entry.FailureOriginId = entity.FailureOriginId; entry.FailureRate = entity.FailureRate; entry.StatusId = entity.StatusId; entry.Analyst = entity.Analyst; entry.RequestDate = entity.RequestDate; entry.SamplesArriveDate = entity.SamplesArriveDate; entry.PriorityId = entity.PriorityId; entry.InitialReportTargetDate = entity.InitialReportTargetDate; entry.BUId = entity.BUId; entry.Product = entity.Product; entry.FailureDesc = entity.FailureDesc; entry.FinalReportTargetDate = entity.FinalReportTargetDate; entry.Submitted = entity.Submitted; entry.Customer = entity.Customer; entry.LabSiteId = entity.LabSiteId; entry.RatingId = entity.RatingId; entry.Comments = entity.Comments; entry.IsDeleted = entity.IsDeleted; entry.LastUpdatedBy = entity.LastUpdatedBy; entry.LastUpdate = DateTime.Now; context.Entry<FAR_Master>(entry).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(MSTProductDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { MST_Product add = context.MST_Product.Create(); add.Description = entity.Description; add.MainPerson = entity.MainPerson; add.SecondaryPerson = entity.SecondaryPerson; add.TertiaryPerson = entity.TertiaryPerson; add.LabSiteId = entity.LabSiteId; add.Name = entity.Name; add.IsDeleted = false; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<MST_Product>(add).State = System.Data.Entity.EntityState.Added; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(MSTProductDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var product = context.MST_Product.Single(x => x.Id == entity.Id && x.IsDeleted == false); product.Name = entity.Name; product.MainPerson = entity.MainPerson; product.SecondaryPerson = entity.SecondaryPerson; product.TertiaryPerson = entity.TertiaryPerson; product.LabSiteId = entity.LabSiteId; product.IsDeleted = entity.IsDeleted; product.Description = entity.Description; product.LastUpdatedBy = entity.LastUpdatedBy; product.LastUpdate = DateTime.Now; context.Entry<MST_Product>(product).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(MSTCustomerDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { MST_Customer add = context.MST_Customer.Create(); add.CustomerName = entity.CustomerName; add.EndCustomer = entity.EndCustomer; add.Location = entity.Location; add.Strategic = entity.Strategic; add.IsDeleted = entity.IsDeleted; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<MST_Customer>(add).State = System.Data.Entity.EntityState.Added; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Deletes the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> DeleteAsync(FARAnalystReassignLogDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var reassign = context.LOG_FARAnalystReassign.Single(x => x.Id == entity.Id && x.IsDeleted == false); reassign.IsDeleted = true; reassign.LastUpdate = DateTime.Now; reassign.LastUpdatedBy = entity.LastUpdatedBy; context.Entry<LOG_FARAnalystReassign>(reassign).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Deletes the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> DeleteAsync(MSTFarReportDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var report = context.MST_FARReport.Single(x => x.Id == entity.Id && x.IsDeleted == false); report.IsDeleted = true; context.Entry<MST_FARReport>(report).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(RecordLockDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var update = context.FAR_RecordLock.Single(x => x.Id == entity.Id && x.IsDeleted == false); update.ProcessHistoryId = entity.ProcessHistoryId; update.LockBy = entity.LockBy; update.LockDate = entity.LockDate; update.MasterId = entity.MasterId; update.ReleaseDate = entity.ReleaseDate; update.LastUpdatedBy = entity.LastUpdatedBy; update.LastUpdate = DateTime.Now; context.Entry<FAR_RecordLock>(update).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(LOGProcessHistoryDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { LOG_ProcessHistory add = context.LOG_ProcessHistory.Create(); add.ProcessHisId = entity.ProcessHisId; add.InsertedBy = entity.InsertedBy; add.PlanTo = entity.PlanTo; add.PlanFrom = entity.PlanFrom; add.PlanType = (byte)entity.PlanType; add.Description = entity.Description; add.InsertedDate = DateTime.Now; context.Entry<LOG_ProcessHistory>(add).State = System.Data.Entity.EntityState.Added; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Deletes the by asynchronous. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public async Task<SaveResult> DeleteByAsync(int id) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var record = context.FAR_RecordLock.Single(x => x.Id == id && x.IsDeleted == false); record.IsDeleted = true; record.LastUpdate = DateTime.Now; context.Entry<FAR_RecordLock>(record).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(FARPriorityLogDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var his = context.LOG_FARPriority.Single(x => x.Id == entity.Id && x.IsDeleted == false); his.Id = entity.Id; his.MasterId = entity.MasterId; his.IsDeleted = entity.IsDeleted; his.PriorityOld = entity.PriorityIdOld; his.ReasonId = entity.ReasonId; his.PriorityNew = entity.PriorityIdNew; his.LastUpdatedBy = entity.LastUpdatedBy; his.LastUpdate = DateTime.Now; context.Entry<LOG_FARPriority>(his).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the range asynchronous. /// </summary> /// <param name="entities">The entities.</param> /// <returns></returns> public async Task<SaveResult> AddRangeAsync(IEnumerable<FARUploadDto> entities) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { LOG_FARUpload add = null; foreach (var entity in entities) { add = context.LOG_FARUpload.Create(); add.FileName = entity.FileName; add.MasterId = entity.MasterId; add.ReasonId = entity.ReasonId; add.FAType = entity.FAType; add.UploadedBy = entity.UploadedBy; add.UploadedDate = DateTime.Now; context.Entry<LOG_FARUpload>(add).State = System.Data.Entity.EntityState.Added; } result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(FARPriorityLogDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { LOG_FARPriority add = context.LOG_FARPriority.Create(); add.PriorityOld = entity.PriorityIdOld; add.PriorityNew = entity.PriorityIdNew; add.MasterId = entity.MasterId; add.ReasonId = entity.ReasonId; add.IsDeleted = false; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<LOG_FARPriority>(add).State = System.Data.Entity.EntityState.Added; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(DelayReasonDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var assembly = context.MST_ReasonINIReport.Single(x => x.Id == entity.Id && x.IsDeleted == false); assembly.Description = entity.Description; assembly.LastUpdatedBy = entity.LastUpdatedBy; assembly.LastUpdate = DateTime.Now; context.Entry<MST_ReasonINIReport>(assembly).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(FARMechanismDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { FAR_Mechanism add = context.FAR_Mechanism.Create(); add.Description = entity.Description; add.Name = entity.Name; add.IsDeleted = false; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<FAR_Mechanism>(add).State = System.Data.Entity.EntityState.Added; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(FARInitialTargetLogDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var log = context.LOG_FARInitialTarget.Single(x => x.Id == entity.Id && x.IsDeleted == false); log.MasterId = entity.MasterId; log.ReasonId = entity.ReasonId; log.IsDeleted = entity.IsDeleted; log.TargetDate = entity.TargetDate; log.LastUpdatedBy = entity.LastUpdatedBy; log.LastUpdate = DateTime.Now; context.Entry<LOG_FARInitialTarget>(log).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(MSTProcessProductDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { MST_ProcessProduct add = context.MST_ProcessProduct.Create(); //Check productId and ProcessTypeId exits record? var checkExits = context.MST_ProcessProduct.Where(x => x.ProcessTypeId == entity.ProcessTypeId && x.ProductId == entity.ProductId).FirstOrDefault(); if (checkExits != null) { checkExits.InChargePerson = entity.InChargePerson; checkExits.IsDeleted = false; checkExits.LastUpdatedBy = entity.LastUpdatedBy; checkExits.LastUpdate = DateTime.Now; context.Entry<MST_ProcessProduct>(checkExits).State = System.Data.Entity.EntityState.Modified; } else { add.Description = entity.Description; add.ProductId = entity.ProductId; add.ProcessTypeId = entity.ProcessTypeId; add.InChargePerson = entity.InChargePerson; add.IsDeleted = false; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<MST_ProcessProduct>(add).State = System.Data.Entity.EntityState.Added; } result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> UpdateAsync(MSTServiceDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var service = context.MST_Services.Single(x => x.Id == entity.Id && x.IsDeleted == false); service.Name = entity.Name; service.IsDeleted = entity.IsDeleted; service.Description = entity.Description; service.LastUpdatedBy = entity.LastUpdatedBy; service.LastUpdate = DateTime.Now; context.Entry<MST_Services>(service).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Adds the asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public async Task<SaveResult> AddAsync(FARAnalystReassignLogDto entity) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { LOG_FARAnalystReassign add = context.LOG_FARAnalystReassign.Create(); add.MasterId = entity.MasterId; add.AnalystFrom = entity.AnalystFrom; add.AnalystTo = entity.AnalystTo; add.IsDeleted = entity.IsDeleted; add.LastUpdatedBy = entity.LastUpdatedBy; add.LastUpdate = DateTime.Now; context.Entry<LOG_FARAnalystReassign>(add).State = System.Data.Entity.EntityState.Added; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Deletes the by asynchronous. /// </summary> /// <param name="Id">The identifier.</param> /// <returns></returns> public async Task<SaveResult> DeleteByAsync(int Id) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var assembly = context.MST_Services.Single(x => x.Id == Id && x.IsDeleted == false); assembly.IsDeleted = true; context.Entry<MST_Services>(assembly).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }
/// <summary> /// Deletes the by asynchronous. /// </summary> /// <param name="Id">The identifier.</param> /// <returns></returns> public async Task<SaveResult> DeleteByAsync(int Id) { SaveResult result = SaveResult.FAILURE; try { using (FailureAnalysisEntities context = new FailureAnalysisEntities()) { var final = context.LOG_FARFinalTarget.Single(x => x.Id == Id && x.IsDeleted == false); final.IsDeleted = true; final.LastUpdate = DateTime.Now; context.Entry<LOG_FARFinalTarget>(final).State = System.Data.Entity.EntityState.Modified; result = await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } } catch (Exception ex) { _logService.Error(ex.Message, ex); result = SaveResult.FAILURE; } return result; }