public IHttpActionResult PostModule(ModuleDTO module)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            try
            {
                bizModule.createModule(module);
            }
            catch (DbUpdateException)
            {
                if (ModuleExists(module.ModuleId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = module.ModuleId }, module));
        }
        public ActionResult EditMenu(Guid?id, Guid?moduleId)
        {
            var modules = _moduleService.ListAll();

            ViewBag.Modules = modules;

            ModuleDTO module = null;

            var menu = id.HasValue ? _menuService.FindBy(id.Value) : new MenuDTO();

            if (menu.Id != Guid.Empty && menu.Module != null)
            {
                module = menu.Module;
            }

            if (moduleId.HasValue)
            {
                module = modules.FirstOrDefault(x => x.Id == moduleId.Value);
            }

            ViewBag.Module = module ?? new ModuleDTO();

            ViewBag.Menus = _menuService.FindBy(module == null ? Guid.Empty : module.Id, string.Empty, 1, int.MaxValue).ToList();

            return(View(menu));
        }
Esempio n. 3
0
        public List <ModuleDTO> ShowRoleFunctions(string ID)
        {
            NpgsqlDataReader npgdr     = null;
            List <ModuleDTO> lstJquery = new List <ModuleDTO>();

            try
            {
                string strlocation = "select f.functionid,f.functionname,f.functionurl,f.moduleid,m.modulename from tabfunctions f left join tabmodules m on m.moduleid=f.moduleid order by modulename;";
                strlocation = "select x.functionid,functionname,functionurl,x.moduleid,modulename,coalesce(status,false) as status from (select f.functionid,f.functionname,f.functionurl,f.moduleid,m.modulename  from tabfunctions f left join tabmodules m on m.moduleid=f.moduleid  where moduletype in ('RMS') order by modulename)x left join (SELECT functionid,moduleid,true as status FROM tabrolefunctions where userid=" + ID + ")y on x.moduleid=y.moduleid and x.functionid=y.functionid;";
                strlocation = "select x.functionid,functionname,functionurl,x.moduleid, modulename,coalesce(status,false) as status from (select f.functionid,f.functionname,f.functionurl,f.moduleid,m.parentmodulename||'_'||m.modulename as  modulename from tabfunctions f left join tabmodules m on m.moduleid=f.moduleid  where moduletype in ('RMS') order by modulename)x left join (SELECT functionid,moduleid,true as status FROM tabrolefunctions where userid=" + ID + ")y on x.moduleid=y.moduleid and x.functionid=y.functionid;";
                npgdr       = NPGSqlHelper.ExecuteReader(NPGSqlHelper.SQLConnString, CommandType.Text, strlocation);
                while (npgdr.Read())
                {
                    ModuleDTO obj = new ModuleDTO();
                    obj.functionid   = Convert.ToInt32(npgdr["functionid"].ToString());
                    obj.functionname = npgdr["functionname"].ToString();
                    obj.functionurl  = npgdr["functionurl"].ToString();
                    obj.Moduleid     = Convert.ToInt32(npgdr["moduleid"].ToString());
                    obj.modulename   = npgdr["modulename"].ToString();
                    obj.chkStatus    = Convert.ToBoolean(npgdr["status"]);
                    lstJquery.Add(obj);
                }
            }
            catch (Exception ex)
            {
                EventLogger.WriteToErrorLog(ex, "UserRights");
            }
            finally
            {
                npgdr.Dispose();
            }
            return(lstJquery);
        }
Esempio n. 4
0
        public List <ModuleDTO> ModueTypeChange(string Type, string Form)
        {
            List <ModuleDTO> lstmodule = new List <ModuleDTO>();
            DataSet          ds        = new DataSet();

            try
            {
                string strGetCountry = "select distinct  parentmoduleid,parentmodulename from tabmodules where parentmodulename is not null  and moduletype in ('" + Type + "') and parentmoduleid is not null order by parentmodulename;";
                ds = NPGSqlHelper.ExecuteDataset(NPGSqlHelper.SQLConnString, CommandType.Text, strGetCountry);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        ModuleDTO objC = new ModuleDTO();
                        objC.ModuleId         = Convert.ToInt32(ds.Tables[0].Rows[i]["parentmoduleid"]);
                        objC.ParentModulename = ds.Tables[0].Rows[i]["parentmodulename"].ToString();
                        lstmodule.Add(objC);
                    }
                }
            }
            catch (Exception ex)
            {
                EventLogger.WriteToErrorLog(ex, "UserRights");
            }
            finally
            {
                ds.Dispose();
            }
            return(lstmodule);
        }
Esempio n. 5
0
        public ActionResult EditModule(string Id)
        {
            Module    mt   = CommonSrv.LoadObjectById(typeof(Module), Id) as Module;
            ModuleDTO mdto = new ModuleDTO();

            mdto.Id           = mt.Id;
            mdto.ModuleTypeId = mt.ModuleType.Id;
            mdto.ModuleUrl    = mt.ModuleUrl;
            mdto.Name         = mt.Name;
            mdto.OrderId      = mt.OrderId;
            mdto.Remark       = mt.Remark;
            mdto.Tag          = mt.Tag;
            //获取 syscode - rights
            SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");

            if (sct != null)
            {
                foreach (SysCode sc in sct.SysCodes)
                {
                    if (mt.ModuleRights.ContainsKey(sc.Tag))
                    {
                        mdto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id + "|√");
                    }
                    else
                    {
                        mdto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id);
                    }
                }
            }
            return(View("ModuleInfo", mdto));
        }
Esempio n. 6
0
        public List <ModuleDTO> ShowModuleName()
        {
            List <ModuleDTO> lstModule = new List <ModuleDTO>();

            try
            {
                string str = "select modulename,moduleid from tabmodules where statusid=1 and moduletype in ('RMS','HRMS');";
                npgdr = NPGSqlHelper.ExecuteReader(NPGSqlHelper.SQLConnString, CommandType.Text, str);
                while (npgdr.Read())
                {
                    ModuleDTO objModuleDTO = new ModuleDTO();
                    objModuleDTO.Moduleid   = Convert.ToInt32(npgdr["moduleid"]);
                    objModuleDTO.Modulename = npgdr["modulename"].ToString();
                    lstModule.Add(objModuleDTO);
                }
            }
            catch (Exception ex)
            {
                EventLogger.WriteToErrorLog(ex, "UserRights");
            }
            finally
            {
                npgdr.Dispose();
            }
            return(lstModule);
        }
        public IHttpActionResult PutModule(string id, ModuleDTO module)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != module.ModuleId)
            {
                return(BadRequest());
            }



            try
            {
                bizModule.updateModule(module);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModuleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostModule(ModuleDTO moduleDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (moduleDTO == null)
            {
                return(BadRequest("Missing Values"));
            }

            //if (name == null)
            //    return BadRequest("One or more parameters missing values");

            Module module = Mapper.Map <Module>(moduleDTO);

            ModuleRepo.Add(module);

            try
            {
                ModuleRepo.Save();
                return(Ok(module));
            }
            catch
            {
                return(BadRequest("Failed to add module"));
            }
        }
Esempio n. 9
0
        public static string GetOperationLog(this ModuleDTO entity, ModuleDTO oldDTO = null)
        {
            var sb = new StringBuilder();

            if (oldDTO == null)
            {
                sb.AppendLine(string.Format("{0}: {1}", CommonMessageResources.Name, entity.Name));
                sb.AppendLine(string.Format("{0}: {1}", CommonMessageResources.SortOrder, entity.SortOrder));
            }
            else
            {
                if (entity.Name != oldDTO.Name)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                CommonMessageResources.Name, oldDTO.Name, entity.Name));
                }
                if (entity.SortOrder != oldDTO.SortOrder)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                CommonMessageResources.SortOrder, oldDTO.SortOrder, entity.SortOrder));
                }
            }

            return(sb.ToString().TrimEnd('\r', '\n'));
        }
Esempio n. 10
0
        public async Task <ActionResult <ModuleDTO> > PostModule(ModuleDTO model)
        {
            try
            {
                if (model == null)
                {
                    return(BadRequest("No entity provided"));
                }


                var id = await _crudService.CreateAsync <ModuleDTO, Module>(model);

                if (id < 1)
                {
                    return(BadRequest("Unable to add the entity"));
                }

                var dto = await _crudService.GetSingleAsync <Module, ModuleDTO>(s => s.Id.Equals(id), true);

                if (dto == null)
                {
                    return(BadRequest("Cannot create entity"));
                }

                var uri = _linkGenerator.GetPathByAction("GetSingleModule", "Modules", new { id });

                return(Created(uri, dto));
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Server Failure!"));
            }
        }
Esempio n. 11
0
        // ---------------------------------------------------------------------------------------------
        public ModuleDTO GetDTOWithQuestions(edumodule module, int userId)
        {
            ModuleDTO moduleDTO = ModuleMapper.GetDTO(module);
            List <TestQuestionDTO> questionDtosOfModule = QuestionDtosForModule(module);
            List <TestCodeDTO>     codeDtosOfModule     = CodeDtosForModule(module);


            // Wersja dla NAUCZYCIELA (do edycji modułów)
            // .........................................................................
            // brak id użytkownika - pytania będą zawierać indeks prawidłowej odpowiedzi
            // - ta wersja potrzebna jest do edycji modułów
            if (userId < 0)
            {
                moduleDTO.test_questions_DTO = questionDtosOfModule;
                moduleDTO.test_codes_DTO     = codeDtosOfModule;
                return(moduleDTO);
            }


            // Wersja dla STUDENTA
            // .........................................................................
            // Jest id uzytkownika -
            // - pytania będą zawierały indeks ostatniej odpowiedzi udzielonej przez użytkownika
            // - kody będą zawierały kody utworzone przez użytkownika
            // (zamiana indeksów prawidłowych odpowiedzi na ostatnie odpowiedzi podane przez użytkownika
            // i prawidłowych wyników kodu na kody utworzone przez użytkownika).
            moduleDTO.test_questions_DTO = SetStudentAnswers(userId, questionDtosOfModule);
            moduleDTO.test_codes_DTO     = SetStudentCodes(userId, codeDtosOfModule);


            // moduł gotowy do wysłania studentowi
            return(moduleDTO);
        }
Esempio n. 12
0
        public async Task <ActionResult <ModuleDTO> > PutModule(int id, ModuleDTO model)
        {
            try
            {
                if (model == null)
                {
                    return(BadRequest("No entity provided"));
                }
                if (!id.Equals(model.Id))
                {
                    return(BadRequest("Differing Ids"));
                }

                var exist1 = await _crudService.AnyAsync <Course>(c => c.Id.Equals(model.CourseId));

                if (!exist1)
                {
                    return(NotFound("Cant find related id in VideoDTO"));
                }

                if (await _crudService.UpdateAsync <ModuleDTO, Module>(model))
                {
                    return(NoContent());
                }
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Failed to add the entity"));
            }

            return(BadRequest("Cannot update"));
        }
        public ModuleDTO Add(ModuleDTO moduleDTO)
        {
            var module = moduleDTO.ToModel();

            module.Id      = IdentityGenerator.NewSequentialGuid();
            module.Created = DateTime.UtcNow;

            if (module.Name.IsNullOrBlank())
            {
                throw new DefinedException(UserSystemMessagesResources.Name_Empty);
            }

            if (_Repository.Exists(module))
            {
                throw new DataExistsException(string.Format(UserSystemMessagesResources.Module_Exists_WithValue, module.Name));
            }

            _Repository.Add(module);

            #region 操作日志

            var moduleDto = module.ToDto();

            OperateRecorder.RecordOperation(moduleDto.Id.ToString(),
                                            UserSystemMessagesResources.Add_Module,
                                            moduleDto.GetOperationLog());

            #endregion

            //commit the unit of work
            _Repository.UnitOfWork.Commit();

            return(module.ToDto());
        }
        public async Task <IActionResult> Edit(int id, ModuleDTO moduleDto)
        {
            if (id != moduleDto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var sucess = await _apiService.UpdateAsync <Module, ModuleDTO>(moduleDto);
                }
                catch
                {
                }

                return(RedirectToAction(nameof(Index)));
            }

            var course = await _apiService.GetAsync <Course, CourseDTO>(true);

            ViewData["CourseId"] = new SelectList(course, "Id", "CourseTitle");

            return(View(moduleDto));
        }
Esempio n. 15
0
        /// <summary>
        /// 新增模块。
        /// </summary>
        /// <param name="dto">待新增模块的信息。</param>
        /// <returns>新模块的Id。(-2:Tag重复。)</returns>
        public static string InsertModule(ModuleDTO dto)
        {
            Module existingM = GetModuleByTag(dto.Tag);

            if (existingM != null)
            {
                return("-2");
            }

            Db.SessionFactory.EvictQueries("Module");

            //模块基本信息。
            Module m = new Module();

            m.Id        = IdGen.GetNextId(typeof(Module));
            m.Tag       = dto.Tag;
            m.Name      = dto.Name;
            m.Remark    = dto.Remark;
            m.OrderId   = dto.OrderId;
            m.ModuleUrl = dto.ModuleUrl;
            m.Disabled  = dto.Disabled;

            //模块分类。
            ModuleType mt = Db.Session.Load(typeof(ModuleType), dto.ModuleTypeId) as ModuleType;

            mt.AddModule(m);

            //获取新增模块权限的主键值。
            string[] Ids = null;
            if (dto.ModuleRights.Count > 0)
            {
                Ids = IdGen.GetNextId(typeof(ModuleRight), dto.ModuleRights.Count);
            }

            //向数据库保存模块和模块权限。
            ITransaction transaction = Db.Session.BeginTransaction();

            try
            {
                Db.Session.Save(m);
                for (int i = 0; i < dto.ModuleRights.Count; i++)
                {
                    ModuleRight mr = new ModuleRight();
                    mr.Id       = Ids[i];
                    mr.RightTag = dto.ModuleRights[i].ToString();
                    m.AddModuleRight(mr);
                    Db.Session.Save(mr);
                }
                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw;
            }

            //返回新模块的Id。
            return(m.Id);
        }
Esempio n. 16
0
 // ---------------------------------------------------------------------------------------------
 private int SortModules(ModuleDTO a, ModuleDTO b)
 {
     if (a.group_position != b.group_position)
     {
         return(a.group_position > b.group_position ? 1 : -1);
     }
     return(a.id > b.id ? 1 : -1);
 }
 public void createModule(ModuleDTO newModule)
 {
     using (var db = new ProjectDbContext())
     {
         var module = DTOEFMapper.GetEntityFromDTO(newModule);
         db.Modules.Add(module);
         db.SaveChanges();
     }
 }
Esempio n. 18
0
        public ActionResult Get(Guid ID)
        {
            ModuleDTO ModuleDTO = new ModuleDTO();

            using (ServiceProxy <IWebService> proxy = new ServiceProxy <IWebService>())
            {
                ModuleDTO = proxy.Channel.GetModuleByID(ID);
            }
            return(Json(ModuleDTO));
        }
Esempio n. 19
0
 // ---------------------------------------------------------------------------------------------
 public static void CopyValues(ModuleDTO source, edumodule target)
 {
     target.id             = source.id;
     target.parent         = source.parent;
     target.group_position = source.group_position;
     target.title          = source.title;
     target.difficulty     = source.difficulty;
     target.content        = source.content;
     target.example        = source.example;
 }
Esempio n. 20
0
 public async Task AddModule([FromBody] ModuleDTO input)
 {
     pcontext.Module.Add(new ModuleEntity
     {
         Name    = input.Name,
         Code    = input.Code,
         AppCode = input.AppCode
     });
     await pcontext.SaveChangesAsync();
 }
Esempio n. 21
0
        public static ModuleDTO ConvertToModuleDto(Module module)
        {
            ModuleDTO moduleDTO = new ModuleDTO();

            moduleDTO.ModuleId   = module.ModuleId;
            moduleDTO.ModuleName = module.ModuleName;
            moduleDTO.IsActive   = module.IsActive;

            return(moduleDTO);
        }
Esempio n. 22
0
        public static void ConvertToModuleEntity(ref Module module, ModuleDTO moduleDTO, bool isUpdate)
        {
            if (isUpdate)
            {
                moduleDTO.ModuleId = module.ModuleId;
            }

            moduleDTO.ModuleName = module.ModuleName;
            moduleDTO.IsActive   = module.IsActive;
        }
Esempio n. 23
0
        public void UpdateModule(ModuleDTO moduleDTO)
        {
            Module module = new Module();

            ModuleConvertor.ConvertToModuleEntity(ref module, moduleDTO, true);
            UnitOfWork unitOfWork = new UnitOfWork();

            unitOfWork.ModuleDashboardRepository.Update(module);
            unitOfWork.SaveChanges();
        }
Esempio n. 24
0
        public ModuleDTO GetModuleById(int moduleId)
        {
            ModuleDTO moduleDTO = null;
            var       module    = unitOfWork.ModuleDashboardRepository.GetById(moduleId);

            if (module != null)
            {
                moduleDTO = ModuleConvertor.ConvertToModuleDto(module);
            }
            return(moduleDTO);
        }
Esempio n. 25
0
        public ActionResult DeleteComposantDetail(int idToDelete)
        {
            CardComposantViewModel modelOut = new CardComposantViewModel();
            CompositionDTO         cpstion  = new CompositionDTO();
            ModuleDTO mdl = new ModuleDTO();
            int       idModule;
            decimal   prixComposant;

            try
            {
                cpstion       = Mapper.Map <Composition, CompositionDTO>(_compositionService.Get(idToDelete));
                prixComposant = Convert.ToDecimal(cpstion.composant.prixHT * (1 + (cpstion.composant.gamme.pourcentageGamme / 100)));
                _compositionService.Delete(idToDelete, _donneNomPrenomUtilisateur());
                _compositionService.Save();

                //On récupère les caractéristiques du module
                idModule = _compositionService.Get(idToDelete).module.id;
                mdl      = Mapper.Map <Module, ModuleDTO>(_moduleService.Get(idModule));
                mdl.prix = Decimal.Subtract(mdl.prix, prixComposant);
                _moduleService.Update(Mapper.Map <ModuleDTO, Module>(mdl), _donneNomPrenomUtilisateur());
                _moduleService.Save();

                //On reconstruit le tableau récapitulant les composants de l'employé
                modelOut.tableauComposant.avecActionCrud = false;
                modelOut.tableauComposant.lesLignes.Add(new List <object> {
                    "Composant", "Prix fournisseur", "Prix de vente", "Gamme", ""
                });
                List <Composition> composition1 = new List <Composition>();
                composition1 = _compositionService.DonneTousComposants(idModule);


                if (composition1.Count != 0)
                {
                    foreach (Composition cpst1 in composition1)
                    {
                        modelOut.tableauComposant.lesLignes.Add(new List <object> {
                            cpst1.composant.libe, cpst1.composant.prixHT.ToString(), (cpst1.composant.prixHT * (1 + (cpst1.composant.gamme.pourcentageGamme / 100))).ToString(), cpst1.composant.gamme.libe, cpst1.id
                        });
                    }
                }

                modelOut.lesComposants = _donneListeComposants();

                FlashMessage.Confirmation("Composant mis à jour avec succès");
            }
            catch (Exception e)
            {
                FlashMessage.Danger("Erreur lors de la mise à jour du composant");

                return(PartialView("~/Areas/RechercheDeveloppement/Views/Module/_CardComposantPartial.cshtml", modelOut));
            }

            return(PartialView("~/Areas/RechercheDeveloppement/Views/Module/_CardComposantPartial.cshtml", modelOut));
        }
Esempio n. 26
0
 public ModuleDTO CreateModule(Guid webid, ModuleDTO moduledto)
 {
     try
     {
         return(webServiceImpl.CreateModule(webid, moduledto));
     }
     catch (Exception ex)
     {
         throw new FaultException <FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
     }
 }
Esempio n. 27
0
 public ModuleDTO EditModule(ModuleDTO moduledto)
 {
     try
     {
         return(webServiceImpl.EditModule(moduledto));
     }
     catch (Exception ex)
     {
         throw new FaultException <FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
     }
 }
 public void updateModule(ModuleDTO updateModule)
 {
     using (var db = new ProjectDbContext())
     {
         var module = db.Modules.Where(m => m.ModuleId == updateModule.ModuleId).FirstOrDefault();
         if (module != null)
         {
             db.Entry(module).CurrentValues.SetValues(updateModule);
             db.SaveChanges();
         }
     }
 }
Esempio n. 29
0
 public static ModuleView CastWithoutList(ModuleDTO moduleDTO)
 {
     if (moduleDTO == null)
     {
         return(null);
     }
     return(new ModuleView
     {
         Id = moduleDTO.Id,
         Name = moduleDTO.Name
     });
 }
        public IHttpActionResult DeleteModule(string id)
        {
            ModuleDTO module = bizModule.findById(id);

            if (module == null)
            {
                return(NotFound());
            }

            bizModule.deleteModule(id);

            return(Ok(module));
        }