Example #1
0
        public async Task <ActionResult <Brand> > PutBrand(int id, BrandInputDto input)
        {
            var brand = await _context.Brands.FindAsync(id);

            brand.Name                  = input.Name;
            brand.ArabicName            = input.ArabicName;
            brand.UpdatedUserId         = input.UserId;
            brand.UpdatedDate           = DateTime.Now;
            _context.Entry(brand).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BrandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(brand);
        }
Example #2
0
        public async Task <ActionResult <LicenceType> > PutLicenceType(int id, LicenceTypeInputDto input)
        {
            var licenceType = await _context.LicenceTypes.FindAsync(id);

            licenceType.Name                  = input.Name;
            licenceType.ArabicName            = input.ArabicName;
            licenceType.UpdatedUserId         = input.UserId;
            licenceType.UpdatedDate           = DateTime.Now;
            _context.Entry(licenceType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LicenceTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(licenceType);
        }
Example #3
0
        public async Task <ActionResult <Question> > PutBrand(int id, QuestionInputDto input)
        {
            var question = await _context.Questions.FindAsync(id);

            question.QuestionTitle       = input.QuestionTitle;
            question.ArabicQuestionTitle = input.ArabicQuestionTitle;
            question.AnswerContent       = input.AnswerContent;
            question.ArabicAnswerContent = input.ArabicAnswerContent;
            question.Order                 = (int)input.Order.Value;
            question.UpdatedUserId         = input.UserId;
            question.UpdatedDate           = DateTime.Now;
            _context.Entry(question).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(question);
        }
        public async Task <ActionResult <ProductType> > PutProductType(int id, ProductTypeInputDto input)
        {
            var productType = await _context.ProductTypes.FindAsync(id);

            productType.ArabicDescription   = input.ArabicDescription;
            productType.Description         = input.Description;
            productType.ArabicHowToActivate = input.ArabicHowToActivate;
            productType.HowToActivate       = input.HowToActivate;
            productType.ArabicName          = input.ArabicName;
            productType.Name                  = input.Name;
            productType.LicenceTypeId         = input.LicenceTypeId;
            productType.PlatformId            = input.PlatformId;
            productType.BrandId               = input.BrandId;
            productType.UpdatedUserId         = input.UserId;
            productType.UpdatedDate           = DateTime.Now;
            _context.Entry(productType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(productType);
        }
        public async Task <ActionResult <Platform> > PutPlatform(int id, PlatformInputDto input)
        {
            var platform = await _context.Platforms.FindAsync(id);

            platform.Name                  = input.Name;
            platform.ArabicName            = input.ArabicName;
            platform.UpdatedUserId         = input.UserId;
            platform.UpdatedDate           = DateTime.Now;
            _context.Entry(platform).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlatformExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(platform);
        }
Example #6
0
        public async Task <User> PutUser(InputUserDto input)
        {
            var usr = await _userManager.FindByIdAsync(input.Id);

            try
            {
                if (usr == null)
                {
                    return(null);
                }
                usr.Email                 = input.Email;
                usr.PhoneNumber           = input.Phone;
                usr.UserName              = input.UserName;
                usr.IsAdmin               = input.IsAdmin;
                usr.HasWrittingAccess     = input.HasWrittingAccess;
                usr.IsCustomer            = input.IsCustomer;
                _context.Entry(usr).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(usr);
        }
Example #7
0
        public async Task <IActionResult> PutCodeDetail(int id, CodeDetail CodeDetail)
        {
            if (id != CodeDetail.CId)
            {
                return(BadRequest());
            }
            _context.Entry(CodeDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CodeDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <int> BlockCode(BlockInputDto input)
        {
            var redeemCode = await _context.RedeemCodes.FindAsync(input.Id);

            if (redeemCode == null)
            {
                return(0);
            }
            redeemCode.Status                = Domain.Enums.Status.Blocked;
            redeemCode.UpdatedUserId         = input.UserId;
            redeemCode.UpdatedDate           = DateTime.Now;
            _context.Entry(redeemCode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(-1);
            }

            return(1);
        }
Example #9
0
        public async Task <ActionResult <Customer> > PutCustomer(int id, CustomerInputDto input)
        {
            var customer = await _context.Customers.FindAsync(id);

            var usr = await _userManager.FindByIdAsync(input.UserId);

            usr.Email                      = input.Email;
            usr.PhoneNumber                = input.Phone;
            customer.FirstName             = input.FirstName;
            customer.LastName              = input.LastName;
            customer.Email                 = input.Email;
            customer.Country               = input.Country;
            customer.City                  = input.City;
            customer.Phone                 = input.Phone;
            customer.UpdatedUserId         = input.UpdatedUserId;
            customer.UpdatedDate           = DateTime.Now;
            _context.Entry(customer).State = EntityState.Modified;
            _context.Entry(usr).State      = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(customer);
        }
 public void Update(Category category)
 {
     db.Entry(category).State = EntityState.Modified;
 }
 public void Update(CustomerOffer customerOffer)
 {
     db.Entry(customerOffer).State = EntityState.Modified;
 }
Example #12
0
 public void Update(Company company)
 {
     db.Entry(company).State = EntityState.Modified;
 }
 public void Update(Offer offer)
 {
     db.Entry(offer).State = EntityState.Modified;
 }
 public void Update(CompanyOffer companyOffer)
 {
     db.Entry(companyOffer).State = EntityState.Modified;
 }
Example #15
0
 public void Update(Executor executor)
 {
     db.Entry(executor).State = EntityState.Modified;
 }