[Route("api/suggestion/create")] //UID public async Task <HttpResponseMessage> create(HttpRequestMessage request, [FromBody] tbSuggestion obj) { tbSuggestion result; obj.Accesstime = DateTime.UtcNow.getLocalTime(); if (obj.ID == default(int)) { var code = Convert.ToInt32(repo.GetWithoutTracking().Where(d => d.IsDeleted != true).Select(d => d.CodeIndex ?? 0).DefaultIfEmpty(0).Max()); obj.IsDeleted = false; obj.Code = "S".getCode(code + 1, "000000"); obj.CodeIndex = code + 1; result = repo.AddWithGetObj(obj); if (result != null) { //await BookSendApiRequestHelper.SendMessage(string.Format("Your service ticket ID is {0}. Please use that for customer service enquiry and any kind of support.", result.Code), obj.UserId); } } else { result = repo.UpdatewithObj(obj); } HttpResponseMessage response = request.CreateResponse <tbSuggestion>(HttpStatusCode.OK, result); return(response); }
public static async Task <tbSuggestion> CreateOrEdit(tbSuggestion obj) { return(await ApiRequest <tbSuggestion> .PostRequest("api/suggestion/create", obj)); }