Exemple #1
0
        public async Task <IResponse <Action> > UpdateAsync(Action model)
        {
            var action = await _authUow.ActionRepo.FindAsync(model.ActionId);

            if (action == null)
            {
                return new Response <Action> {
                           Message = ServiceMessage.RecordNotExist.Fill(DomainStrings.Action)
                }
            }
            ;

            action.Name           = model.Name;
            action.ControllerName = model.ControllerName;
            action.ActionName     = null;// model.ActionName;
            action.Icon           = model.Icon;
            action.ParentId       = model.ParentId;
            action.ShowInMenu     = model.ShowInMenu;
            action.ActionName     = model.ActionName;
            action.OrderPriority  = model.OrderPriority;

            var saveResult = await _authUow.ElkSaveChangesAsync();

            return(new Response <Action> {
                Result = action, IsSuccessful = saveResult.IsSuccessful, Message = saveResult.Message
            });
        }
Exemple #2
0
        public async Task <IResponse <Action> > AddAsync(Action model)
        {
            await _authUow.ActionRepo.AddAsync(model);

            var saveResult = _authUow.ElkSaveChangesAsync();

            return(new Response <Action> {
                Result = model, IsSuccessful = saveResult.Result.IsSuccessful, Message = saveResult.Result.Message
            });
        }
 public virtual async Task <JsonResult> Update(Action model)
 {
     if (model.ParentId != null && (string.IsNullOrWhiteSpace(model.ControllerName) || string.IsNullOrWhiteSpace(model.ActionName)))
     {
         return(Json(new Response <string> {
             IsSuccessful = false, Message = Strings.ValidationFailed
         }));
     }
     ModelState.Remove(nameof(model.ParentId));
     if (!ModelState.IsValid)
     {
         return(Json(new Response <string> {
             IsSuccessful = false, Message = ModelState.GetModelError()
         }));
     }
     return(Json(await _actionSrv.UpdateAsync(model)));
 }