public bool UpdateClient(Models.Client.Client client) { bool isUpdate = true; using (SqlConnection connection = new SqlConnection(CommonUtility.ConnectionString)) { SqlCommand command = new SqlCommand(StoreProcedure.UPDATECLIENT, connection); command.CommandType = CommandType.StoredProcedure; foreach (var clients in client.GetType().GetProperties()) { string name = clients.Name; var value = clients.GetValue(client, null); command.Parameters.Add(new SqlParameter("@" + name, value == null ? DBNull.Value : value)); } try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception e) { isUpdate = false; throw new Exception("Exception Updating Data." + e.Message); } finally { connection.Close(); } } return(isUpdate); }
public Models.Client.Client GetClientByEmailAndPassword(string email, string password) { using (SqlConnection connection = new SqlConnection(CommonUtility.ConnectionString)) { SqlCommand command = new SqlCommand(StoreProcedure.Get_Client_By_Email_And_Password, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Email", email)); command.Parameters.Add(new SqlParameter("@Password", password)); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); Models.Client.Client client = new Models.Client.Client(); client = UtilityManager.DataReaderMap <Models.Client.Client>(reader); return(client); } catch (Exception e) { throw new Exception("Exception retrieving reviews. " + e.Message); } finally { connection.Close(); } } }
public Models.Client.Client GetClientById(long clientId) { using (SqlConnection connection = new SqlConnection(CommonUtility.ConnectionString)) { SqlCommand command = new SqlCommand(StoreProcedure.GETCLIENTBYID, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@ClientId", clientId)); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); Models.Client.Client client = new Models.Client.Client(); client = UtilityManager.DataReaderMap <Models.Client.Client>(reader); return(client); } catch (Exception e) { throw new Exception("Exception retrieving reviews. " + e.Message); } finally { connection.Close(); } } }
public async Task <Models.Client.Client> Create(ICreate request) { var entity = new Models.Client.Client { Id = new Guid(), Name = request.Name, OrgID = request.OrgID }; await _dbContext.Clients.AddAsync(entity); await _dbContext.SaveChangesAsync(); return(entity); }
public long InsertClient(Models.Client.Client client) { long id = 0; using (SqlConnection connection = new SqlConnection(CommonUtility.ConnectionString)) { SqlCommand command = new SqlCommand(StoreProcedure.INSERTCLIENT, connection); command.CommandType = CommandType.StoredProcedure; SqlParameter returnValue = new SqlParameter("@" + "ClientId", SqlDbType.Int); returnValue.Direction = ParameterDirection.Output; command.Parameters.Add(returnValue); foreach (var clients in client.GetType().GetProperties()) { if (clients.Name != "ClientId") { string name = clients.Name; var value = clients.GetValue(client, null); command.Parameters.Add(new SqlParameter("@" + name, value == null ? DBNull.Value : value)); } } try { connection.Open(); command.ExecuteNonQuery(); id = (int)command.Parameters["@ClientId"].Value; } catch (Exception ex) { throw new Exception("Execption Adding Data. " + ex.Message); } finally { connection.Close(); } } return(id); }
public ActionResult Create(Models.Client.Client clientVm) { var newClient = _clientManager.CreateClient(clientVm.ClientName); return(RedirectToAction("Edit", new { id = newClient.clientid })); }
public ActionResult Edit(Models.Client.Client clientVm, string sort) { _clientManager.UpdateClient(clientVm.ClientId, clientVm.ClientName); ViewBag.SuccessMessage = "Updated Successfully"; return(View(GetClient(clientVm.ClientId, ToSortType(sort)))); }