public ActionResult Edit(string id, PaymentType paymentType) { try { var objectId = ObjectId.Parse(id); var doc = new BsonDocument { { "code", paymentType.Code }, { "name", paymentType.Name } }; repository.Update(objectId, doc); return(RedirectToAction("Index")); } catch { return(null); } }
public IActionResult Update([FromRoute] string id, [FromBody] PaymentTypeRequest request) { try { if (string.IsNullOrWhiteSpace(request.Code)) { return(BadRequest("Invalid code")); } if (string.IsNullOrWhiteSpace(request.Description)) { return(BadRequest("Invalid description")); } var type = _repository.GetByUserID(UserID, id); if (type == null) { return(BadRequest("Invalid payment type")); } if (type.Code != request.Code && _paymentRepository.ListPayment(UserID, type.Id).Any()) { return(BadRequest("Can't change type code becaure the folder is already created")); } type.Description = request.Description; type.UpdateDate = DateTime.Now; _repository.Update(id, type); var response = _mapper.Map <PaymentType, PaymentTypeResponse>(type); return(Ok(response)); } catch (Exception) { throw; } }
public void Update(PaymentType payment_type) { _repository.Update(payment_type); }