예제 #1
0
        public async Task <IHttpActionResult> Put([FromODataUri] int CustomerCategoryID, CustomerCategory item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (CustomerCategoryID == item.CustomerCategoryID)
            {
                return(BadRequest());
            }

            item.ObjectState = ObjectState.Modified;
            _service.Update(item);

            try
            {
                await _unitOfWorkAsync.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(CustomerCategoryID))
                {
                    return(NotFound());
                }
                throw;
            }

            return(Updated(item));
        }
예제 #2
0
 public JavaScriptResult Edit(CustomerCategoryViewModel customerCategoryVm)
 {
     try
     {
         _customerCategoryService.Update(Mapper.Map <CustomerCategory>(customerCategoryVm));
         return(JavaScript($"ShowResult('{"Data saved successfully."}','{"success"}','{"redirect"}','{"/APanel/CustomerCategory"}')"));
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }