public HttpResponseMessage Update([FromBody] StoreUpdateRequest request, int id) { request.StoreId = id; var response = _externalCommandService.Execute(request); return(Request.CreateResponse(response)); }
public ExecuteResult<StoreInfoResponse> UpdateStore(StoreUpdateRequest request) { if (request == null) { return new ExecuteResult<StoreInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" }; } var entity = this._storeRepsitory.GetItem(request.StoreId); if (entity == null) { return new ExecuteResult<StoreInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误,没有找到指定storeid" }; } var source = MappingManager.StoreEntityMapping(request); // source => target source.CreatedDate = entity.CreatedDate; source.CreatedUser = entity.CreatedUser; source.Status = (int)DataStatus.Normal; MappingManager.StoreEntityMapping(source, entity); this._storeRepsitory.Update(entity); return new ExecuteResult<StoreInfoResponse>(MappingManager.StoreResponseMapping(entity)); }
public ExecuteResult <StoreInfoResponse> UpdateStore(StoreUpdateRequest request) { if (request == null) { return(new ExecuteResult <StoreInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" }); } var entity = this._storeRepsitory.GetItem(request.StoreId); if (entity == null) { return(new ExecuteResult <StoreInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误,没有找到指定storeid" }); } var source = MappingManager.StoreEntityMapping(request); // source => target source.CreatedDate = entity.CreatedDate; source.CreatedUser = entity.CreatedUser; source.Status = (int)DataStatus.Normal; MappingManager.StoreEntityMapping(source, entity); this._storeRepsitory.Update(entity); return(new ExecuteResult <StoreInfoResponse>(MappingManager.StoreResponseMapping(entity))); }
public bool Update(StoreUpdateRequest entity) { Store existed = _repo.GetById(entity.Id); if (existed == null) { return(false); } int brandId = entity.BrandId; string name = entity.Name; string address = entity.Address; string phone = entity.Phone; if (brandId > 0) { existed.BrandId = brandId; } if (name != null) { if (!util.ValidRangeLengthInput(name, 1, 100)) { return(false); } Store existedName = _repo.GetAll().FirstOrDefault(e => e.Name.ToLower().Equals(name.ToLower())); if (existedName != null) { if (existedName.Id != entity.Id) { return(false); } } existed.Name = name.Trim(); } if (phone != null) { if (!util.ValidFixedLengthInput(phone, 10)) { return(false); } existed.Phone = phone.Trim(); } if (address != null) { if (!util.ValidRangeLengthInput(address, 1, 250)) { return(false); } existed.Address = address.Trim(); } return(_repo.Update(existed)); }
public ActionResult PutStore(int id, StoreUpdateRequest entity) { if (id != entity.Id) { return(BadRequest()); } bool success = _ser.Update(entity); if (success) { var updated = _ser.GetById(entity.Id); return(Ok(updated)); } return(Problem("Update failed!")); }
public async Task <IActionResult> PutStore(int id, StoreUpdateRequest request) { if (id != request.Id) { return(BadRequest()); } var store = new Store() { Id = id, AutoAccept = request.AutoAccept, Image = request.Image, Name = request.Name, //TODO review //Products = request.Products, StoreLocation = StoreLocation.Parse(request.StoreLocation ?? new StoreLocationRequest()), }; _context.Entry(store).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public HttpResponseMessage GetById(StoreUpdateRequest request) { var response = _businessAdminExternalCommandService.Execute<StoreUpdateRequest, StoreUpdateResponse, StoreUpdateCommand>(request); return Request.CreateResponse(response); }