Exemple #1
0
        public string Validate(RepresenteeDTO Representee)
        {
            if (null == Representee)
            {
                return(GenericMessages.ObjectIsNull);
            }

            if (Representee.Address == null)
            {
                return("Address " + GenericMessages.ObjectIsNull);
            }

            if (String.IsNullOrEmpty(Representee.FullName))
            {
                return(Representee.FullName + " " + GenericMessages.StringIsNullOrEmpty);
            }

            if (Representee.FullName.Length > 255)
            {
                return(Representee.FullName + " can not be more than 255 characters ");
            }

            if (!string.IsNullOrEmpty(Representee.AuthorizationNumber) && Representee.AuthorizationNumber.Length > 50)
            {
                return(Representee.AuthorizationNumber + " can not be more than 50 characters ");
            }


            return(string.Empty);
        }
Exemple #2
0
        public bool ObjectExists(RepresenteeDTO Representee)
        {
            return(false);
            //var objectExists = false;
            //var iDbContext = DbContextUtil.GetDbContextInstance();
            //try
            //{
            //    var catRepository = new Repository<RepresenteeDTO>(iDbContext);
            //    var catExists = catRepository.Query()
            //        .Filter(bp => (!string.IsNullOrEmpty(bp.TinNumber) && bp.TinNumber == Representee.TinNumber) &&
            //                      bp.Id != Representee.Id)
            //        .Get()
            //        .FirstOrDefault();


            //    if (catExists != null)
            //        objectExists = true;
            //}
            //finally
            //{
            //    iDbContext.Dispose();
            //}

            //return objectExists;
        }
Exemple #3
0
        public string InsertOrUpdate(RepresenteeDTO representee)
        {
            try
            {
                var validate = Validate(representee);
                if (!string.IsNullOrEmpty(validate))
                {
                    return(validate);
                }

                if (ObjectExists(representee))
                {
                    return(GenericMessages.DatabaseErrorRecordAlreadyExists + Environment.NewLine +
                           "With the same name exists");
                }

                _representeeRepository.InsertUpdate(representee);
                _unitOfWork.Commit();
                return(string.Empty);
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
        }
Exemple #4
0
        public string Disable(RepresenteeDTO representee)
        {
            //if (_unitOfWork.Repository<DeliveryHeaderDTO>().Query().Get().Any(i => i.RepresenteeId == Representee.Id) ||
            //    _unitOfWork.Repository<DocumentDTO>().Query().Get().Any(i => i.RepresenteeId == Representee.Id))
            //{
            //    return "Can't delete the item, it is already in use...";
            //}

            if (representee == null)
            {
                return(GenericMessages.ObjectIsNull);
            }

            string stat;

            try
            {
                _representeeRepository.Update(representee);
                _unitOfWork.Commit();
                stat = string.Empty;
            }
            catch (Exception exception)
            {
                stat = exception.Message;
            }
            return(stat);
        }
 public RepresenteeEntryUC(RepresenteeDTO addressDTO)
 {
     RenteeEntryViewModel.Errors = 0;
     CompanyViewModel.Errors     = 0;
     InitializeComponent();
     Messenger.Default.Send <RepresenteeDTO>(addressDTO);
     Messenger.Reset();
 }