예제 #1
0
        public JsonResult Edit(Brand model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }));
                }

                Brand itemFound = BrandManager.GetById(model.kBrandId);
                if (itemFound == null)
                {
                    return(Json(new { Result = "ERROR", Message = "Item Not Found" }));
                }
                model.dtDateAdd    = itemFound.dtDateAdd;
                model.dtDateUpdate = DateTime.Now;

                BrandManager.Edit(model);

                var clientName = User.Identity.Name;
                Task.Factory.StartNew(() =>
                {
                    var clients = Hub.GetClients <RealTimeJTableDemoHub>();
                    clients.RecordUpdated(clientName, model);
                });
                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }