Beispiel #1
0
        public async Task <AtNotify> EditMenuFuntionAsyns(MenuFunctionDmCreatetInputOrEdit input, string userId)
        {
            try
            {
                var model = await _context.MenuFunction.FirstOrDefaultAsync(c => c.Id == input.Id);

                if (model == null)
                {
                    return(AtNotify.NotFound);
                }

                string data_old = JsonConvert.SerializeObject(model);

                var mapper = _mapper.Map(input, model);

                await _context.SaveChangesAsync();

                string data_new = JsonConvert.SerializeObject(mapper);

                await WrtiteAudittingLog(new MSC_AudittingLog { Description = "Chỉnh sửa MenuFunction " + input.Id, UserID = userId, Data_New = data_new, Data_Old = data_old }, AtSerialNoConts.CODE_LOGC_UPDATE);

                return(AtNotify.UpdateCompelete);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public async Task <MenuFunctionDmOutput> CreateMenuFuntionAsyns(MenuFunctionDmCreatetInputOrEdit input, string userId)
        {
            try
            {
                var mapper = _mapper.Map <MenuFunction>(input);
                mapper.Id = await GetSerialCode(AtSerialNoConts.CODE_MENUFUNCTION);

                mapper.CreateDate = GetDateTimeFromServer();
                var result = await _context.MenuFunction.AddAsync(mapper);

                await _context.SaveChangesAsync();

                var output = _mapper.Map <MenuFunctionDmOutput>(result.Entity);

                var subMenu = await _context.MenuFunctionSubGroup.FirstOrDefaultAsync(c => c.Id == result.Entity.FK_MenuSubGroup).ConfigureAwait(false);

                output.NameMenuSubGroup = subMenu.SubGroupName;
                var MenuGroup = await _context.MenuFunctionGroup.FirstOrDefaultAsync(c => c.Id == subMenu.FK_MenuGroup).ConfigureAwait(false);

                output.NameMenuGroup = MenuGroup.GroupName;

                string data_new = JsonConvert.SerializeObject(output);
                await WrtiteAudittingLog(new MSC_AudittingLog { Description = "Thêm mới MenuFunction " + output.Id, UserID = userId, Data_New = data_new }, AtSerialNoConts.CODE_LOG_CREATE);

                return(output);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <ActionResult <AtResult <MenuFunctionDmCreatetInputOrEdit> > > EditMenuFunction(MenuFunctionDmCreatetInputOrEdit input)
        {
            if (await CheckPermission(_context))
            {
                try
                {
                    var output = await _logicMenu.EditMenuFuntionAsyns(input, UserId);

                    if (output == AtNotify.NotFound)
                    {
                        return(new AtResult <MenuFunctionDmCreatetInputOrEdit>(AtNotify.NotFound));
                    }
                    return(new AtResult <MenuFunctionDmCreatetInputOrEdit>(input));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(new AtResult <MenuFunctionDmCreatetInputOrEdit>(AtNotify.KhongCoQuyenTruyCap));
            }
        }
        public async Task <ActionResult <AtResult <MenuFunctionDmOutput> > > CreateMenuFunction(MenuFunctionDmCreatetInputOrEdit input)
        {
            if (await CheckPermission(_context))
            {
                try
                {
                    var model = await _logicMenu.CreateMenuFuntionAsyns(input, UserId);

                    return(new AtResult <MenuFunctionDmOutput>(model));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(new AtResult <MenuFunctionDmOutput>(AtNotify.KhongCoQuyenTruyCap));
            }
        }