コード例 #1
0
        public bool Active(int id)
        {
            var agency = _IAgencyRepository.GetById(id);

            if (agency != null)
            {
                agency.Actived = true;
                _IAgencyRepository.Update(agency);

                return(true);
            }
            return(false);
        }
コード例 #2
0
        public async Task UpdateAccountAsync(int agencyId, UpdateAgencyRequestModel model, CancellationToken ct = default)
        {
            Agency agency = await _agencyRepository.FindByIdAsync(agencyId, ct);

            _mapper.Map(model, agency);
            _agencyRepository.Update(agency);

            await _unitOfWork.SaveChangesAsync(ct);
        }
コード例 #3
0
        public IActionResult Edit(Agency model)
        {
            var result = _agencyRepository.Update(model);

            if (result.Success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                // todo: add validation messages to form later
                throw new Exception(result.Messages[0]);
            }
        }
コード例 #4
0
        public async Task UpdateAccountAsync(UserContextModel userContext, JsonPatchDocument <UpdateAgencyRequestModel> jsonPatch, CancellationToken ct)
        {
            Agency agency = await _agencyRepository.GetAll().Where(x => x.Id == userContext.AgencyId).Include
                                (x => x.Employees).FirstOrDefaultAsync();

            UpdateAgencyRequestModel jsonPatchDTO = _mapper.Map <UpdateAgencyRequestModel>(agency);

            jsonPatch.ApplyTo(jsonPatchDTO);

            _mapper.Map(jsonPatchDTO, agency);

            _agencyRepository.Update(agency);

            await _unitOfWork.SaveChangesAsync();

            //return jsonPatchDTO;
        }
コード例 #5
0
        public IActionResult Edit(int id, Agency agency)
        {
            if (id != agency.AgencyId)
            {
                return(NotFound());
            }

            var response = agencyRepo.Update(agency);

            if (response.Success)
            {
                return(RedirectToAction("Details", new { id = agency.AgencyId }));
            }
            else
            {
                return(BadRequest(response.Message));
            }
        }
コード例 #6
0
        public IActionResult Edit(int id, Agency agency)
        {
            if (id != agency.Id)
            {
                return(NotFound());
            }

            try
            {
                _agencyRepository.Update(agency);
                return(RedirectToAction("Index"));
            }
            catch (DbUpdateConcurrencyException)
            {
                ViewBag.Nationalities               = _personRepository.Nationalities;
                ViewBag.AddressTypes                = _personRepository.AddressTypes;
                ViewBag.PhoneTypes                  = _personRepository.PhoneTypes;
                ViewBag.EmailTypes                  = _personRepository.EmailTypes;
                ViewBag.SocialTypes                 = _personRepository.SocialTypes;
                ViewBag.OTTTypes                    = _personRepository.OTTTypes;
                ViewBag.BankAccountTypes            = _personRepository.BankAccountTypes;
                ViewBag.BankCardTypes               = _personRepository.BankCardTypes;
                ViewBag.Wards                       = _personRepository.Wards;
                ViewBag.DistrictPlaces              = _personRepository.DistrictPlaces;
                ViewBag.Provinces                   = _personRepository.Provinces;
                ViewBag.Representatives             = _personRepository.Representatives;
                ViewBag.Employees                   = _personRepository.Employees;
                ViewBag.AgencyGroups                = _agencyRepository.AgencyGroups;
                ViewBag.AgencyBusinesses            = _agencyRepository.AgencyBusinesses;
                ViewBag.CurrencyTypes               = _agencyRepository.CurrencyTypes;
                ViewBag.PaymentTypes                = _agencyRepository.PaymentTypes;
                ViewBag.PaymentTermTypes            = _agencyRepository.PaymentTermTypes;
                ViewBag.AgencyDiscountTypes         = _agencyRepository.AgencyDiscountTypes;
                ViewBag.PickupTypes                 = _agencyRepository.PickupTypes;
                ViewBag.AgencyDiscountCustomerTypes = _agencyRepository.AgencyDiscountCustomerTypes;

                return(View(agency));
            }
        }