Example #1
0
        private void UpdateExistingClient()
        {
            Console.WriteLine();
            Console.Write("Enter id of client to change: ");
            int id = int.Parse(Console.ReadLine());

            Console.Write("Enter name for this client: ");
            string name = Console.ReadLine();

            Console.Write("Enter surname for this client: ");
            string surname = Console.ReadLine();

            Console.Write("Enter phone number for this client: ");
            string phonenumber = Console.ReadLine();

            Console.Write("Enter account balance for this client: ");
            decimal accountbalance = GetNum();

            UpdateClientInfo changedClient = new UpdateClientInfo
            {
                ID             = id,
                Name           = name,
                Surname        = surname,
                PhoneNumber    = phonenumber,
                AccountBalance = accountbalance
            };
            string result = clientRequests.UpdateClient(changedClient);

            Console.WriteLine("Server answered: " + result);
        }
Example #2
0
        internal string UpdateClient(UpdateClientInfo changedClient)
        {
            string request  = connectionString + "clients/update";
            string jsonData = JsonConvert.SerializeObject(changedClient, Formatting.Indented);
            var    result   = Task.Run(() => Post(request, jsonData));

            return(result.Result);
        }
 public ActionResult <string> UpdateClient([FromBody] UpdateClientInfo updateInfo)
 {
     try
     {
         string result = this.clientService.UpdateClient(updateInfo);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
        public string Update(UpdateClientInfo updateInfo)
        {
            int clientId = updateInfo.ID;

            var clientToUpdate = this.dbContext.Clients.FirstOrDefault(c => c.ID == clientId);

            if (clientToUpdate != null)
            {
                clientToUpdate.Name           = updateInfo.Name;
                clientToUpdate.Surname        = updateInfo.Surname;
                clientToUpdate.PhoneNumber    = updateInfo.PhoneNumber;
                clientToUpdate.AccountBalance = updateInfo.AccountBalance;
                SaveChanges();
                return("Client data updated.");
            }
            return("Client wasn't found.");
        }
Example #5
0
        public string UpdateClient(UpdateClientInfo updateInfo)
        {
            string result = clientTableRepository.Update(updateInfo);

            return(result);
        }