public HttpResponseMessage GetClients() { HttpResponseMessage httpResponse = new HttpResponseMessage(); try { ClientDomainModel objRes = new ClientDomainModel(); objRes.listClients = ClientRepository.GetClients(); if (objRes.listClients != null) { objRes.isSuccess = true; objRes.response = "Success"; httpResponse = Request.CreateResponse(HttpStatusCode.OK, objRes); } else { httpResponse = Request.CreateResponse(HttpStatusCode.Unauthorized, objRes); } return(httpResponse); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "An error occurred, please try again or contact the administrator.", StatusCode = HttpStatusCode.InternalServerError }); } }
public HttpResponseMessage AddUpdateClient(ClientDomainModel model) { try { HttpResponseMessage httpResponse = new HttpResponseMessage(); ResponseDomainModel res = new ResponseDomainModel(); if (model != null) { res = ClientRepository.AddUpdateClient(model); if (res != null && res.isSuccess) { httpResponse = Request.CreateResponse(HttpStatusCode.OK, res); } else { httpResponse = Request.CreateResponse(HttpStatusCode.Unauthorized, res); } } return(httpResponse); } catch (Exception ex) { ErrorLog.LogError(ex); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "An error occurred, please try again or contact the administrator.", StatusCode = HttpStatusCode.InternalServerError }); } }
public ResponseDomainModel AddUpdateClient(ClientDomainModel model) { ResponseDomainModel objRes = new ResponseDomainModel(); try { int ClientId = objHelper.ExecuteScalar("AddUpdateClient", new { ClientId = model.ClientId, FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Skype = model.Skype, Whatsapp = model.Whatsapp, PhoneNumber = model.PhoneNumber, SourceId = model.SourceId, BussinessName = model.BussinessName, Website = model.Website, Location = model.Location, City = model.City, State = model.State, CountryId = model.CountryId, ZipCode = model.ZipCode, GSTNumber = model.GSTNumber, PanNumber = model.PanNumber, PaypalId = model.PaypalId, Remarks = model.Remarks, LinkedInUrl = model.LinkedInUrl, FacebookUrl = model.FacebookUrl, TwitterUrl = model.TwitterUrl, IsActive = true, CreatedDate = DateTime.Now, Archived = model.Archived, CreatedBy = model.CreatedBy }); if (model.ClientId > 0) { objRes.isSuccess = true; objRes.response = "Client updated successfully."; } else if (ClientId > 0) { objRes.isSuccess = true; objRes.response = "Client added successfully."; } else { objRes.isSuccess = false; objRes.response = "Something went wrong, please try again."; } } catch (Exception ex) { ErrorLog.LogError(ex); objRes.isSuccess = false; objRes.response = ex.Message; } return(objRes); }
public ClientDomainModel GetClientById(long ClientId) { ClientDomainModel _details = new ClientDomainModel(); try { _details = objHelper.Query <ClientDomainModel>("GetClientById", new { ClientId = ClientId }).FirstOrDefault(); } catch (Exception ex) { ErrorLog.LogError(ex); } return(_details); }
public ResponseDomainModel AddUpdateClient(ClientDomainModel model) { ResponseDomainModel objRes = new ResponseDomainModel(); try { int ClientId = objHelper.ExecuteScalar("AddUpdateClient", new { ClientId = model.ClientId, FirstName = model.FirstName, LastName = model.LastName, Location = model.Location, TimeZone = model.TimeZone, Email = model.Email, Skype = model.Skype, Whatsapp = model.Whatsapp, PhoneNumber = model.PhoneNumber, IsActive = true, CreatedDate = DateTime.Now, Archived = model.Archived, CreatedBy = model.CreatedBy }); if (model.ClientId > 0) { objRes.isSuccess = true; objRes.response = "Client updated successfully."; } else if (ClientId > 0) { objRes.isSuccess = true; objRes.response = "Client added successfully."; } else { objRes.isSuccess = false; objRes.response = "Something went wrong, please try again."; } } catch (Exception ex) { ErrorLog.LogError(ex); objRes.isSuccess = false; objRes.response = ex.Message; } return(objRes); }
public ActionResult AddUpdateClient(ClientDomainModel model) { if (model != null) { if (model.ClientId == 0) { model.Archived = "NonArchive"; } model.CreatedBy = UserManager.user.UserId; var serialized = new JavaScriptSerializer().Serialize(model); var client = new HttpClient(); var content = new StringContent(serialized, System.Text.Encoding.UTF8, "application/json"); client.BaseAddress = new Uri(HttpContext.Request.Url.AbsoluteUri); var result = client.PostAsync(BaseURL + "/api/Client/AddUpdateClient", content).Result; if (result.StatusCode == HttpStatusCode.OK) { var contents = result.Content.ReadAsStringAsync().Result; var Response = new JavaScriptSerializer().Deserialize <ResponseDomainModel>(contents); } } return(RedirectToAction("_Clients", new { Archived = model.Archived == "NonArchive"?false:true })); }