public IActionResult AddOrEdit(int id, CustomerGroupDto customergroup) { // var id1 = this.GetGroupId(customer); if (ModelState.IsValid) { if (id == 0) { customerGroupService.CreateCustomerGroup(customergroup); } else { try { customerGroupService.UpdateCustomerGroup(customergroup); } catch (DbUpdateConcurrencyException) { if (!customerGroupService.CustomerGroupExists(customergroup.Id)) { return(NotFound()); } else { throw; } } } var customergroups = customerGroupService.GetAll(); return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", customergroups) })); } return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", customergroup) })); }
public async Task <IActionResult> Put([FromBody] CustomerGroupDto model) { if (!await _permissionService.Authorize(PermissionSystemName.Customers)) { return(Forbid()); } var customerGroup = await _mediator.Send(new GetQuery <CustomerGroupDto>() { Id = model.Id }); if (!customerGroup.Any()) { return(NotFound()); } if (ModelState.IsValid && !model.IsSystem) { model = await _mediator.Send(new UpdateCustomerGroupCommand() { Model = model }); return(Ok(model)); } return(BadRequest(ModelState)); }
//Map from Dto to Entity public static CustomerGroup MappingGroup(this CustomerGroupDto customerGroupDto) { return(new CustomerGroup { Id = customerGroupDto.Id, Name = customerGroupDto.Name }); }
public string create(CustomerGroupDto tCustomerGroupDto) { try { CustomerGroup tCustomerGroupNew = mapper.Map <CustomerGroupDto, CustomerGroup>(tCustomerGroupDto); tCustomerGroupNew.Id = Guid.NewGuid().ToString(); tCustomerGroupNew.CreateDate = DateTime.Now; _context.CustomerGroup.Add(tCustomerGroupNew); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
public async Task <IActionResult> Post([FromBody] CustomerGroupDto model) { if (!await _permissionService.Authorize(PermissionSystemName.Customers)) { return(Forbid()); } if (ModelState.IsValid) { model = await _mediator.Send(new AddCustomerGroupCommand() { Model = model }); return(Created(model)); } return(BadRequest(ModelState)); }
//Update public string update(CustomerGroupDto tCustomerGroupDto) { try { CustomerGroup tCustomerGroupUpdate = _context.CustomerGroup.Find(tCustomerGroupDto.Id); if (tCustomerGroupUpdate == null) { return("1"); } tCustomerGroupUpdate.Name = tCustomerGroupDto.Name; tCustomerGroupUpdate.Id = tCustomerGroupDto.Id; tCustomerGroupUpdate.Status = tCustomerGroupDto.Status; tCustomerGroupUpdate.CreateDate = tCustomerGroupDto.CreateDate; tCustomerGroupUpdate.CreateUser = tCustomerGroupDto.CreateUser; _context.CustomerGroup.Update(tCustomerGroupUpdate); _context.SaveChanges(); return("0"); } catch (Exception ex) { return("1"); } }
public string update(CustomerGroupDto customerGroupDto) { try { CustomerGroup customerGroupUpdate = _context.CustomerGroup.Find(customerGroupDto.Id); if (customerGroupUpdate == null) { return("1"); } customerGroupUpdate.Id = customerGroupDto.Id; customerGroupUpdate.Name = customerGroupDto.Name; customerGroupUpdate.Status = customerGroupDto.Status; customerGroupUpdate.CreateDate = customerGroupDto.CreateDate; customerGroupUpdate.CreateUser = customerGroupDto.CreateUser; _context.CustomerGroup.Update(customerGroupUpdate); _context.SaveChanges(); return(""); } catch (Exception) { return("1"); } }
public IActionResult Update([FromBody] CustomerGroupDto value) { string result = _bbService.update(value); return(new ObjectResult(result)); }
//Map from Dto to Entity public static void MappingGroup(this CustomerGroupDto customerGroupDto, CustomerGroup customerGroup) { customerGroup.Id = customerGroupDto.Id; customerGroup.Name = customerGroupDto.Name; }
public void UpdateCustomerGroup(CustomerGroupDto customerGroupDto) { customerGroupRepository.Update(customerGroupDto.MappingGroup()); }
public void DeleteCustomerGroup(CustomerGroupDto customerGroupDto) { customerGroupRepository.Delete(customerGroupDto.MappingGroup()); }
public void CreateCustomerGroup(CustomerGroupDto customerGroupDto) { customerGroupRepository.Add(customerGroupDto.MappingGroup()); }
public static CustomerGroup ToEntity(this CustomerGroupDto model, CustomerGroup destination) { return(model.MapTo(destination)); }
public static CustomerGroup ToEntity(this CustomerGroupDto model) { return(model.MapTo <CustomerGroupDto, CustomerGroup>()); }