Esempio n. 1
0
        public string Validate(RenteeDTO rentee)
        {
            if (null == rentee)
            {
                return(GenericMessages.ObjectIsNull);
            }

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

            if (String.IsNullOrEmpty(rentee.DisplayName))
            {
                return(rentee.DisplayName + " " + GenericMessages.StringIsNullOrEmpty);
            }

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

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


            return(string.Empty);
        }
Esempio n. 2
0
        public bool ObjectExists(RenteeDTO rentee)
        {
            var objectExists = false;
            var iDbContext   = DbContextUtil.GetDbContextInstance();

            try
            {
                var catRepository = new Repository <RenteeDTO>(iDbContext);
                var catExists     = catRepository.Query()
                                    .Filter(bp => (!string.IsNullOrEmpty(bp.TinNumber) && bp.TinNumber == rentee.TinNumber) &&
                                            bp.Id != rentee.Id)
                                    .Get()
                                    .FirstOrDefault();


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

            return(objectExists);
        }
Esempio n. 3
0
        public string Disable(RenteeDTO rentee)
        {
            //if (_unitOfWork.Repository<DeliveryHeaderDTO>().Query().Get().Any(i => i.RenteeId == Rentee.Id) ||
            //    _unitOfWork.Repository<DocumentDTO>().Query().Get().Any(i => i.RenteeId == Rentee.Id))
            //{
            //    return "Can't delete the item, it is already in use...";
            //}

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

            string stat;

            try
            {
                _renteeRepository.Update(rentee);
                _unitOfWork.Commit();
                stat = string.Empty;
            }
            catch (Exception exception)
            {
                stat = exception.Message;
            }
            return(stat);
        }
Esempio n. 4
0
        public string InsertOrUpdate(RenteeDTO rentee)
        {
            try
            {
                var validate = Validate(rentee);
                if (!string.IsNullOrEmpty(validate))
                {
                    return(validate);
                }

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

                _renteeRepository.InsertUpdate(rentee);
                _unitOfWork.Commit();
                return(string.Empty);
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
        }
Esempio n. 5
0
        public async Task <RenteeDTO> AddRentee(RenteeDTO rentee)
        {
            var flag = this.IfRenteeExists(rentee.Username).Result;

            if (flag == false)
            {
                var result = _client.Cypher.Create("(rentee:Rentee {rentee})").WithParams(new { rentee }).Return(rentee => new
                {
                    Rentee = rentee.As <Rentee>()
                }).ResultsAsync;
                Rentee renteee = result.Result.First().Rentee;
                Console.WriteLine(renteee.Id.ToString());
                LoggedUserDTO user = new LoggedUserDTO(rentee.Username, rentee.Password.ToString(), true, "rentee");
                await _redisRepository.AddNewLoggedUser(user);

                return(rentee);
            }
            return(null);
        }
 private void AddNewRentee()
 {
     try
     {
         SelectedRentee = new RenteeDTO
         {
             Type    = RenteeTypes.Organization,
             Address = new AddressDTO
             {
                 Country = "ኢትዮጲያዊ",
                 Region  = "አዲስ አበባ",
                 City    = "አዲስ አበባ"
             },
         };
     }
     catch (Exception)
     {
         //MessageBox.Show("Problem on adding new Rentee");
     }
 }
Esempio n. 7
0
 public async Task <RenteeDTO> CreateRentee([FromBody] RenteeDTO rentee)
 {
     return(await _renteeService.AddRentee(rentee));
 }
Esempio n. 8
0
 public async Task <RenteeDTO> AddRentee(RenteeDTO rentee)
 {
     return(await this._renteeRepository.AddRentee(rentee));
 }