예제 #1
0
        public async Task <IActionResult> Edit([FromBody] string CustomerCard)
        {
            List <CustomerCardRowAddDto> customerCardRowAddDtos = JsonConvert.DeserializeObject <List <CustomerCardRowAddDto> >(CustomerCard);
            CustomerCardAddDto           customerCardAddDto     = new CustomerCardAddDto();
            User user = await _userManager.FindById(Convert.ToInt32(customerCardRowAddDtos[0].ProductManagerName));

            customerCardAddDto.CustomerCardRowAddDto = customerCardRowAddDtos;
            customerCardAddDto.CustomerCardName      = customerCardRowAddDtos[0].CustomerCardName;
            customerCardAddDto.ProductManagerName    = user.Name;
            customerCardAddDto.CustomerCardId        = customerCardRowAddDtos[0].CustomerCardId;
            Customer customer = _customerManager.Find(x => x.CustomerId == Convert.ToInt32(customerCardRowAddDtos[0].CustomerName));

            customerCardAddDto.CustomerName = customer.CustomerName;
            if (ModelState.IsValid)
            {
                List <CustomerCardRow> customerCardRow = _mapper.Map <List <CustomerCardRow> >(customerCardRowAddDtos);
                CustomerCard           customerCardAdd = _mapper.Map <CustomerCard>(customerCardAddDto);
                customerCardRow.ForEach(x => x.CustomerCardId = customerCardAdd.CustomerCardId);
                customerCardAdd.CustomerCardRow = customerCardRow;
                customerCardAdd.CustomerId      = customer.CustomerId;
                customerCardAdd.CostOfCardTime  = customerCardAdd.CustomerCardRow.Count * 4;
                await _customerCardManager.UpdateAsync(customerCardAdd);

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(CustomerCard));
            }
        }
        public async Task <IActionResult> TaskRemove(int id)
        {
            CustomerCardRow customerCardRow = await _customerCardRowManager.FindById(id);

            int          routeId      = customerCardRow.CustomerCardId;
            CustomerCard customerCard = await _customerCardManager.FindById(customerCardRow.CustomerCardId);

            customerCard.CostOfCardTime -= 4;
            await _customerCardManager.UpdateAsync(customerCard);

            await _customerCardRowManager.RemoveAsync(customerCardRow);

            return(RedirectToAction("Index", "Scrum", new { id = routeId }));
        }