Beispiel #1
0
        public async Task <ActionResult <ModuleResponse> > Create([FromBody] ModuleCreateRequest moduleCreateRequest)
        {
            _logger.LogInformationExtension(
                $"Create Module - Name: {moduleCreateRequest.Name}, Code: {moduleCreateRequest.Code}, Module Type: {moduleCreateRequest.ModuleTypeId}, Application: {moduleCreateRequest.ApplicationId}");

            var newModule = await _moduleService.Create(_mapper.Map <ModuleModel>(moduleCreateRequest));

            return(Ok(new Models.Response <ModuleResponse>(_mapper.Map <ModuleResponse>(newModule),
                                                           "Module is successfully created.")));
        }
Beispiel #2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public AjaxResult Create(ModuleDto dto)
        {
            var module = _moduleService.Create(dto);

            if (module == null)
            {
                return(AjaxResult.Error("添加用户失败"));
            }
            return(AjaxResult.Success(module.Id));
        }
Beispiel #3
0
        private void GetModuleBtn_Click(object Sender, EventArgs E)
        {
            StatusLb.Text = "Đang tải...";
            var FileInfos = FileService.ReadAllModuleFromModel(UrlTb.Text);

            ModuleService.Create(FileInfos);
            ModuleService.Delete(EntityTb.Text);
            Console.WriteLine("Done");
            StatusLb.Text = "";
        }
        public async Task <IActionResult> Create([FromForm] ModuleRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _moduleService.Create(request);

            return(Ok(result));
        }
        public async Task <IActionResult> PostModule([FromBody] Module module)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _moduleService.Create(module);

            return(CreatedAtAction("GetModule", new { id = @module.ModuleId }, @module));
        }
Beispiel #6
0
        public async Task <ActionResult <Module> > Create(ModuleRequest module)
        {
            var result = await _modules.Create(module, HttpContext.RequestAborted);

            if (result == null)
            {
                return(Conflict());
            }

            return(result);
        }
Beispiel #7
0
        public ActionResult Edit(ModuleDTO module)
        {
            Module mdl = new Module();

            if (module.id != 0)//update
            {
                try
                {
                    mdl               = _moduleService.Get(module.id);
                    mdl.libe          = module.libe;
                    mdl.prix          = module.prix;
                    mdl.prix          = Convert.ToDecimal(mdl.prix);
                    mdl.coupePrincipe = "string";
                    mdl.typeModule    = _tmoduleService.Get(module.typeModule.id);
                    //mdl = Mapper.Map<ModuleDTO, Module>(module);
                    _moduleService.Update(mdl, _donneNomPrenomUtilisateur());

                    FlashMessage.Confirmation("Module mis à jour avec succès.");
                }
                catch (Exception e)
                {
                    FlashMessage.Danger("Erreur lors de la mise à jour du module");
                }
            }
            else
            {
                try
                {
                    mdl = Mapper.Map <ModuleDTO, Module>(module);

                    int    test  = mdl.typeModule.id;
                    string test2 = mdl.typeModule.libe;
                    int    ind   = mdl.id;

                    //On prépare le type de module
                    mdl.typeModule = _tmoduleService.Get(mdl.typeModule.id);
                    _moduleService.Create(mdl, _donneNomPrenomUtilisateur());

                    FlashMessage.Confirmation("Module créé avec succès. Pour ajouter des composants au module, cliquez sur Détail.");
                }
                catch (Exception e)
                {
                    FlashMessage.Danger("Erreur lors de l'ajout du module");
                }
            }
            _moduleService.Save();

            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        public IActionResult Create([FromBody] ModuleCreateModel model)
        {
            var moduleModel = _mapper.Map <Module>(model);

            try
            {
                moduleModel.UserId = GetUserId();
                var module = _moduleService.Create(moduleModel);
                return(Ok(_mapper.Map <ModuleModel>(module)));
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Beispiel #9
0
        public void RegisterAll()
        {
            var registeredDescriptors = _moduleService.Query(x => x.Sort(s => s.SortAscending(f => f.Identity)));
            var implementTypes        = AssemblyHelper.GetClassOfType(typeof(IModule));
            int nextIdentity          = registeredDescriptors.NotEmpty() ? registeredDescriptors.Last().Identity : 0;

            foreach (var impl in implementTypes)
            {
                var instance   = (IModule)Activator.CreateInstance(impl);
                var descriptor = new ModuleDescriptor();
                instance.Configure().Invoke(descriptor);
                var registeredDescriptor = registeredDescriptors.Find(x => x.Name.IsCaseInsensitiveEqual(descriptor.Name));
                if (registeredDescriptor != null)
                {
                    descriptor.Identity      = registeredDescriptor.Identity;
                    descriptor.LocalizedName = registeredDescriptor.LocalizedName;
                }
                else
                {
                    _moduleService.Create(new Domain.Module
                    {
                        Identity = nextIdentity
                        ,
                        Name = descriptor.Name
                        ,
                        EntryClassName = impl.FullName
                        ,
                        LocalizedName = descriptor.LocalizedName
                    });
                }
                ModuleCollection.Configure((o) =>
                {
                    o.Identity      = descriptor.Identity;
                    o.Name          = descriptor.Name;
                    o.LocalizedName = descriptor.LocalizedName;
                });
                instance.OnStarting();
                nextIdentity++;
            }
        }
Beispiel #10
0
        public HttpResponseMessage Create(HttpRequestMessage request, ModuleViewModel moduleVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                Module moduleDb = new Module();
                moduleDb.UpdateModule(moduleVm);
                _moduleService.Create(moduleDb);
                _moduleService.Save();

                if (moduleVm.Payload == Common.CommonConstants.ModuleAdminContact)
                {
                    MdAdminContact mdAdminContact = new MdAdminContact();
                    mdAdminContact.BotID = moduleVm.BotID;
                    mdAdminContact.MessageStart1 = "Đã thoát trả lời tự động";
                    mdAdminContact.MessageStart2 = "Anh/chị cần tư vấn hay hỗ trợ gì ạ";
                    mdAdminContact.MessageStart3 = "Anh/chị vui lòng chờ một chút, em sẽ chuyển cho chuyên viên hỗ trợ anh/chị ngay";
                    mdAdminContact.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdAdminContact.Title = "Xử lý liên hệ admin";
                    mdAdminContact.DictionaryKey = "admin_contact";
                    mdAdminContact.DictionaryValue = "false";

                    _mdAdminContactService.Create(mdAdminContact);
                    _mdAdminContactService.Save();
                }

                if (moduleVm.Payload == Common.CommonConstants.ModuleEngineerName)
                {
                    MdEngineerName mdEngineerName = new MdEngineerName();
                    mdEngineerName.BotID = moduleVm.BotID;
                    mdEngineerName.MessageStart = "Vui lòng nhập tên kỹ thuật viên nếu có.";
                    mdEngineerName.MessageError = "Không tìm thấy";
                    mdEngineerName.MessageEnd = "Đã nhận thông tin";
                    mdEngineerName.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdEngineerName.Title = "Xử lý tên kỹ sư";
                    mdEngineerName.DictionaryKey = "engineer_name";
                    mdEngineerName.DictionaryValue = "false";

                    _mdEngineerNameService.Create(mdEngineerName);
                    _mdEngineerNameService.Save();
                }

                if (moduleVm.Payload == Common.CommonConstants.ModulePhone)
                {
                    MdPhone mdPhone = new MdPhone();
                    mdPhone.BotID = moduleVm.BotID;
                    mdPhone.MessageStart = "Vui lòng nhập số điện thoại của bạn hoặc chọn bên dưới nếu có.";
                    mdPhone.MessageError = "Số điện thoại không hợp lệ, vui lòng nhập lại!";
                    mdPhone.MessageEnd = "Chúng tôi đã nhận được số điện thoại của bạn. Cảm ơn!";
                    mdPhone.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdPhone.Title = "Xử lý số điện thoại";
                    mdPhone.DictionaryKey = "phone";
                    mdPhone.DictionaryValue = "false";

                    _mdPhoneService.Create(mdPhone);
                    _mdPhoneService.Save();
                }
                if (moduleVm.Payload == Common.CommonConstants.ModuleEmail)
                {
                    MdEmail mdEmail = new MdEmail();
                    mdEmail.BotID = moduleVm.BotID;
                    mdEmail.MessageStart = "Vui lòng nhập email của bạn hoặc chọn bên dưới nếu có.";
                    mdEmail.MessageError = "Địa chỉ email không hợp lệ, vui lòng nhập lại!";
                    mdEmail.MessageEnd = "Cảm ơn bạn đã cung cấp thông tin!";
                    mdEmail.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdEmail.Title = "Xử lý email";
                    mdEmail.DictionaryKey = "email";
                    mdEmail.DictionaryValue = "false";

                    _mdEmailService.Create(mdEmail);
                    _mdEmailService.Save();
                }
                if (moduleVm.Payload == Common.CommonConstants.ModuleAge)
                {
                    MdAge mdAge = new MdAge();
                    mdAge.BotID = moduleVm.BotID;
                    mdAge.MessageStart = "Bạn vui lòng cho tôi biết độ tuổi của bạn.";
                    mdAge.MessageError = "Tôi không nghĩ đó là số tuổi, bạn vui lòng nhập vào chữ số.";
                    mdAge.MessageEnd = "Cảm ơn bạn, chúng tôi đã tiếp nhận thông tin thành công!";
                    mdAge.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdAge.Title = "Xử lý tuổi";
                    mdAge.DictionaryKey = "age";
                    mdAge.DictionaryValue = "false";

                    _mdAgeService.Create(mdAge);
                    _mdAgeService.Save();
                }
                //if (moduleVm.Payload == Common.CommonConstants.ModuleVoucher)
                //{
                //    MdVoucher mdVoucher = new MdVoucher();
                //    mdVoucher.BotID = moduleVm.BotID;
                //    mdVoucher.MessageStart = "Bạn vui lòng nhập số điện thoại để nhận voucher.";
                //    mdVoucher.MessageError = "Số điện thoại không đúng, bạn vui lòng nhập lại.";
                //    mdVoucher.MessageEnd = "Cảm ơn bạn, chúng đã tiếp nhận thông tin thành công!";
                //    mdVoucher.ModuleID = moduleDb.ID;
                //    //mdPhone.CardPayloadID = null;
                //    //mdPhone.Payload = "";
                //    mdVoucher.Title = "Xử lý voucher";
                //    mdVoucher.DictionaryKey = "voucher";
                //    mdVoucher.DictionaryValue = "false";

                //    _mdVoucherService.Create(mdVoucher);
                //    _mdVoucherService.Save();
                //}

                response = request.CreateResponse(HttpStatusCode.OK, moduleDb);
                return response;
            }));
        }
Beispiel #11
0
 public Core.Dto.Module Post(Core.Dto.Module module)
 {
     return(_moduleService.Create(module));
 }
 public JsonResult Create(ModuleDto model)
 {
     _moduleService.Create(model);
     return(Json(1, JsonRequestBehavior.AllowGet));
 }
Beispiel #13
0
        public JsonResult Save(ModuleEditViewModel model)
        {
            var result = new JsonResultBO(true);

            try
            {
                if (ModelState.IsValid)
                {
                    if (model.Id <= 0)
                    {
                        if (_moduleService.CheckExistCode(model.Code))
                        {
                            throw new Exception(string.Format("Mã {0} đã tồn tại", model.Code));
                        }
                        Module entity = new Module()
                        {
                            Code     = model.Code,
                            ClassCss = model.ClassCss,
                            StyleCss = model.StyleCss,
                            Icon     = model.Icon,
                            Name     = model.Name,
                            IsShow   = model.IsShow,
                            Order    = model.Order.ToNumber <int>()
                        };
                        _moduleService.Create(entity);
                        _Ilog.InfoFormat("Thêm mới module {0}", model.Name);
                    }
                    else
                    {
                        if (_moduleService.CheckExistCode(model.Code, model.Id))
                        {
                            throw new Exception(string.Format("Mã {0} đã tồn tại", model.Code));
                        }
                        Module entity = _moduleService.GetById(model.Id);
                        entity.Code     = model.Code;
                        entity.ClassCss = model.ClassCss;
                        entity.StyleCss = model.StyleCss;
                        entity.Icon     = model.Icon;
                        entity.Name     = model.Name;
                        entity.IsShow   = model.IsShow;
                        entity.Order    = model.Order.ToNumber <int>();
                        _moduleService.Update(entity);

                        _Ilog.InfoFormat("Cập nhật module {0}", model.Name);
                    }


                    return(Json(result));
                }
                result.Message = ModelState.GetErrors();
                result.Status  = false;
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
                _Ilog.Error("Lỗi cập nhật thông tin Module", ex);
            }
            return(Json(result));
        }