private void ExcuteAddNewCpoCommand() { if (SelectedWarehouse != null && SelectedWarehouse.Id != -1) { SelectedCpo = new CpoDTO { PreparedDate = DateTime.Now, IsReturned = false, WarehouseId = SelectedWarehouse.Id }; AddNewCpoCommandVisibility = true; SaveCpoCommandVisibility = true; } }
public string Disable(CpoDTO cpo) { if (cpo == null) { return(GenericMessages.ObjectIsNull); } string stat; try { _cpoRepository.Update(cpo); _unitOfWork.Commit(); stat = string.Empty; } catch (Exception exception) { stat = exception.Message; } return(stat); }
public string Validate(CpoDTO cpo) { if (null == cpo) { return(GenericMessages.ObjectIsNull); } if (String.IsNullOrEmpty(cpo.Number)) { return(cpo.Number + " " + GenericMessages.StringIsNullOrEmpty); } if (String.IsNullOrEmpty(cpo.ToCompany)) { return(cpo.ToCompany + " " + GenericMessages.StringIsNullOrEmpty); } if (cpo.Amount < 1 || cpo.Amount > 1000000) { return(" cpo Amount is above allowed limit"); } return(string.Empty); }
public bool ObjectExists(CpoDTO cpo) { var objectExists = false; var iDbContext = DbContextUtil.GetDbContextInstance(); try { var catRepository = new Repository <CpoDTO>(iDbContext); var catExists = catRepository.Query() .Filter(bp => bp.Number == cpo.Number && bp.Id != cpo.Id) .Get() .FirstOrDefault(); if (catExists != null) { objectExists = true; } } finally { iDbContext.Dispose(); } return(objectExists); }
public string InsertOrUpdate(CpoDTO cpo) { try { var validate = Validate(cpo); if (!string.IsNullOrEmpty(validate)) { return(validate); } if (ObjectExists(cpo)) { return(GenericMessages.DatabaseErrorRecordAlreadyExists); } _cpoRepository.InsertUpdate(cpo); _unitOfWork.Commit(); return(string.Empty); } catch (Exception exception) { return(exception.Message); } }