Пример #1
0
        public object Put(JObject updatedJSON)
        {
            IDictionary <String, object> updated = updatedJSON.ToObject <IDictionary <String, object> >();

            object json;

            try
            {
                string        messageError = "";
                Models.Vendor putting      = repository.Update(updated, ref messageError);

                if (putting != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = putting,
                        success = true
                    };
                }
                else
                {
                    json = new
                    {
                        message = messageError,
                        success = false
                    };
                }
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }
Пример #2
0
        public ActionResult Edit(VendorVm model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var vendor  = _mapper.Map <Vendor>(model);
                var isvalid = _repo.Update(vendor);

                if (!isvalid)
                {
                    ModelState.AddModelError("", "Could not edit vendors. Try Again");
                    return(View(model));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Could not edit vendors. Try Again");
                return(View());
            }
        }