Esempio n. 1
0
        public async Task <Enterprise> EditEnterpriseProfile(EditEnterpriseParameters enterprise)
        {
            var enterprisee = await context.Enterprises.Include(i => i.Address).FirstOrDefaultAsync(i => i.Id == enterprise.EnterpriseId);

            enterprisee.Name             = enterprise.Name;
            enterprisee.Description      = enterprise.Description;
            enterprisee.Address.City     = enterprise.Address.City;
            enterprisee.Address.Country  = enterprise.Address.Country;
            enterprisee.Address.Street   = enterprise.Address.Street;
            enterprisee.Address.StreetNo = enterprise.Address.StreetNo;
            enterprisee.Address.ZipCode  = enterprise.Address.ZipCode;

            return(enterprisee);
        }
Esempio n. 2
0
        public async Task <Enterprise> AddEnterprise(EditEnterpriseParameters enterprise)
        {
            var enterprisee = new Enterprise();

            enterprisee.Address          = new EnterpriseAddress();
            enterprisee.Name             = enterprise.Name;
            enterprisee.Description      = enterprise.Description;
            enterprisee.Address.City     = enterprise.Address.City;
            enterprisee.Address.Country  = enterprise.Address.Country;
            enterprisee.Address.Street   = enterprise.Address.Street;
            enterprisee.Address.StreetNo = enterprise.Address.StreetNo;
            enterprisee.Address.ZipCode  = enterprise.Address.ZipCode;

            context.Enterprises.Add(enterprisee);
            return(enterprisee);
        }
        public async Task <Enterprise> AddEnterprise(EditEnterpriseParameters enterprise)
        {
            try
            {
                var temp = await repo.AddEnterprise(enterprise);

                if (temp != null)
                {
                    await unitOfWork.CompleteAsync();
                }
                return(temp);
            }
            catch
            {
                return(null);
            }
        }
        public async Task <IActionResult> EditEnterpriseProfile(EditEnterpriseParameters enterprise)
        {
            if (ModelState.IsValid)
            {
                var temp = await enterpriseService.EditEnterpriseProfile(enterprise);

                if (temp != null)
                {
                    return(Ok(temp));
                }
                else
                {
                    return(BadRequest(new { Message = "Something went wrong. Please, try again later." }));
                }
            }
            else
            {
                return(BadRequest(new { Message = "Invalid parameters supplied." }));
            }
        }