Ejemplo n.º 1
0
        public IHttpActionResult Add(Uom model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var retId = _uomService.Add(model);

                if (retId == 0)
                {
                    Log.Info($"{typeof(UomController).FullName}||{UserEnvironment}||Add record not successful, Uom Code is duplicate.");
                    return(Content(HttpStatusCode.Forbidden, "Uom Code is Duplicate"));
                }
                else
                {
                    var response = Request.CreateResponse(HttpStatusCode.Created);
                    var test     = JsonConvert.SerializeObject(new
                    {
                        id      = retId,
                        message = "Unit of measure added"
                    });
                    Log.Info($"{typeof(UomController).FullName}||{UserEnvironment}||Add record successful.");
                    response.Content = new StringContent(test, Encoding.UTF8, "appliation/json");
                    return(ResponseMessage(response));
                }
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Ejemplo n.º 2
0
 public JavaScriptResult Create(UomViewModel uOMvm)
 {
     try
     {
         _uomService.Add(Mapper.Map <Uom>(uOMvm));
         return(JavaScript($"ShowResult('{"Data saved successfully."}','{"success"}','{"redirect"}','{"/APanel/UOM"}')"));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }