public async Task <ICommandOutput> Handler(ClientUpdate command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados Inválidos", command.Notifications)); } var name = new Name(command.FirstName, command.LastName); var document = new Document(command.NuberDocument); if (name.Invalid) { new GenericCommandResult(false, "Dados do name inválidos", name.Notifications); } if (document.Invalid) { new GenericCommandResult(false, "Dados do documento inválidos", document.Notifications); } var client = await _repositoryClient.GetById(command.Id); client.Update(command.FirstName, command.LastName, command.NuberDocument, command.Telephone, command.Address); await _repositoryClient.Update(client); return(new GenericCommandResult(true, "Dados do cliente atualizados com sucesso", client)); }
// GET: Client/Edit/ public async Task <ActionResult> Edit(Guid id) { var client = await _repositoryClient.GetById(id); ViewBag.success = false; var _clientUpdate = new ClientUpdate(client.Id, client.Name.FirstName, client.Name.LastName, client.CPF.Number, client.Telephone, client.Address); return(PartialView(_clientUpdate)); }
public override void Add(WishClient obj) { var clientexist = _repositoryClient.GetById(obj.Client.Id); if (clientexist == null) { Errors.Add(new Error("003", "Cliente não existe na base de dados!")); return; } var productexist = _repositoryProduct.GetByProductTitle(obj.Product.Title.ToString()); if (productexist == null) { Errors.Add(new Error("003", "Produto não existe na base de dados!")); return; } var wishclientexist = _repositoryWishClient.GetByClientEmail(clientexist.Email.ToString()); if (wishclientexist != null) { var productexistinwichlist = _repositoryWishClient.ProductExistInWish(wishclientexist.Id, obj.Product.Title.ToString()); if (productexistinwichlist) { Errors.Add(new Error("003", "O produto selecionado já consta na lista de desejos!")); return; } _repositoryWishClient.AddItem(obj); } else { var wishlist = WishClient.WishClientBuilder(clientexist, productexist); _repositoryWishClient.Add(wishlist); obj.SetId(wishlist.Id); obj.SetProduct(productexist); _repositoryWishClient.AddItem(obj); } }