Exemplo n.º 1
0
        public JsonResult Create(Color model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }));
                }
                var colorCount = ColorManager.GetCountDuplicate(model.sDescription.Trim());
                if (colorCount >= 1)
                {
                    return(Json(new { Result = "ERROR", Message = "Item Exists." }));
                }

                model.kColorId = Guid.NewGuid();

                ColorManager.Create(model);
                return(Json(new { Result = "OK", Record = model }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }