Example #1
0
        public async Task <IActionResult> PostDomain([FromBody] Domain domain, [FromBody] TimeDuration timeduration, [FromBody] int length)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (domain.Customer == null || domain.CustomerId == null)
            {
                return(BadRequest("Domain is not associated with a valid user"));
            }

            var customer = _customerRepository.GetCustomer(domain.CustomerId.Value).Result;

            if (customer == null)
            {
                return(BadRequest("customer is not valid for domain"));
            }

            if (string.IsNullOrEmpty(customer.ContactId) || string.IsNullOrEmpty(customer.ProviderName))
            {
                return(BadRequest("Customer is not verified yet"));
            }

            var today = DateTime.Today;

            domain.ExpiriationDate = timeduration == TimeDuration.YEAR ? today.AddYears(length) : today.AddMonths(length);

            await _domainRepository.AddDomain(domain);

            return(CreatedAtAction("GetDomain", new { id = domain.DomainId }, domain));
        }
Example #2
0
 public async Task <ServiceResult> AddDomain(DomainAdd model)
 {
     return(await _domainRepository.AddDomain(model));
 }