Example #1
0
 private void ExcuteAddNewCpoCommand()
 {
     if (SelectedWarehouse != null && SelectedWarehouse.Id != -1)
     {
         SelectedCpo = new CpoDTO
         {
             PreparedDate = DateTime.Now,
             IsReturned   = false,
             WarehouseId  = SelectedWarehouse.Id
         };
         AddNewCpoCommandVisibility = true;
         SaveCpoCommandVisibility   = true;
     }
 }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
            }
        }