async public virtual Task <ActionResult> Create() { ActionResult result = BadRequest(); try { await _service.Create <T>(); ApiResponseBase response = new ApiResponseBase() { success = true, data = null, message = null }; } catch (Exception ex) { ApiResponseBase response = new ApiResponseBase() { success = false, data = null, message = ex.Message }; result = BadRequest(response); } return(result); }
public string Add() { var reader = new StreamReader(Request.Body); var txt = reader.ReadToEnd(); var p = JsonConvert.DeserializeObject <User>(txt); var user = _service.Create(p); if (HttpContext == null) { return(CustomJsonResult.Instance.GetSuccess(user)); } HttpContext.Session.Set <User>("user" + user.Id, user); Console.WriteLine(HttpContext.Session.Get <User>("user" + user.Id).Name); return(CustomJsonResult.Instance.GetSuccess(user)); }
private void CreateExecute() { var product = new Product() { Title = this.Title, Price = this.Price }; if (repositoryGeneric.Create(product)) { this.RespCreated = $"Producto Creado Exitosamente"; this.Title = string.Empty; this.Price = 0; } else { this.RespCreated = $"Error al Crear el Producto en la Base de Datos"; } }