public int UpdateRegisterMessr(TblRegisterMessrs model) { try { var recordToUpdateInDb = dbContext.TblRegisterMessrs.Where(x => x.Id == model.Id).FirstOrDefault(); if (recordToUpdateInDb != null) { var duplicateNameRecord = dbContext.TblRegisterMessrs.Where(x => x.Id != model.Id && x.PhoneNo == model.PhoneNo).FirstOrDefault(); if (duplicateNameRecord != null) { return(0); } else { recordToUpdateInDb.Name = model.Name; recordToUpdateInDb.PhoneNo = model.PhoneNo; return(dbContext.SaveChanges()); } } else { return(0); } } catch (Exception ex) { StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Repository name: {nameof(ReceiptRepository)} - Method name: {nameof(UpdateRegisterMessr)}", stackTrace: ex.StackTrace); return(0); } }
public IActionResult PutRegisterMessrs(TblRegisterMessrs model) { try { return(Ok(rp.UpdateRegisterMessr(model))); } catch (Exception ex) { Exceptions(ex); return(StatusCode(500)); } }
public int UpdateRegisterMessr(TblRegisterMessrs model) { try { return(receipt.UpdateRegisterMessr(model)); } catch (Exception ex) { StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Class Name: {nameof(ReceiptPresenter)} - Method name: {nameof(UpdateRegisterMessr)}", stackTrace: ex.StackTrace); return(0); } }
public int CreateRegisterMessr(TblRegisterMessrs model) { try { var IsRegisterMessrExists = dbContext.TblRegisterMessrs.Where(x => x.PhoneNo == model.PhoneNo).FirstOrDefault(); if (IsRegisterMessrExists != null) { return(0); } else { dbContext.Add(model); return(dbContext.SaveChanges()); } } catch (Exception ex) { StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Repository name: {nameof(ReceiptRepository)} - Method name: {nameof(CreateRegisterMessr)}", stackTrace: ex.StackTrace); return(0); } }