Пример #1
0
 public IActionResult Create(Setting setting)
 {
     if (ModelState.IsValid)
     {
         _settingService.Create(setting);
         _settingService.Commit();
         return(RedirectToAction("Index"));
     }
     return(View(setting));
 }
Пример #2
0
        public ActionResult AddNew(Setting model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { IsCompleted = false }, JsonRequestBehavior.AllowGet));
            }

            model.Status = Status.Active;

            _settingService.Create(model);

            return(View());
        }
Пример #3
0
        public ActionResult CreateOrSave(SettingViewModel model)
        {
            var setting = _settingService.GetSetting(model.Id);

            if (setting != null)
            {
                if (!setting.Name.Equals(model.Name) && CheckNameIsExsist(model.Name))
                {
                    return(Json(
                               new
                    {
                        success = false,
                        message = $"{model.Name} đã tồn tại. Vui lòng chọn tên khác"
                    }
                               , JsonRequestBehavior.AllowGet));
                }

                var localeByMap = Mapper.Map(model, setting);
                _settingService.Update(localeByMap);
            }
            else
            {
                if (CheckNameIsExsist(model.Name))
                {
                    return(Json(
                               new
                    {
                        success = false,
                        message = $"{model.Name} đã tồn tại. Vui lòng chọn tên khác"
                    }
                               , JsonRequestBehavior.AllowGet));
                }

                var localeByMap = Mapper.Map <SettingViewModel, Setting>(model);
                _settingService.Create(localeByMap);
            }

            return(Json(
                       new
            {
                success = true
            }
                       , JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public HttpResponseMessage Create(SettingModel model)
        {
            if (string.IsNullOrEmpty(model.Value))
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据不允许为空!")));
            }
            var setting = new SettingEntity
            {
                Key   = model.Key,
                Value = model.Value
            };

            if (_settingService.Create(setting) != null)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功")));
            }
            else
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败")));
            }
        }
Пример #5
0
        public IActionResult Create(CreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var chief = _chiefService.GetByUsername(model.UserName);

            if (chief == null)
            {
                var newChief = new Chief
                {
                    IdentificationNumber = model.IdentificationNumber,
                    Name        = model.Name,
                    Surname     = model.Surname,
                    UserName    = model.UserName,
                    Password    = model.Password,
                    Town        = model.Town,
                    District    = model.District,
                    City        = model.City,
                    CreatedDate = DateTime.Now
                };

                _chiefService.Create(newChief);

                _settingService.Create(new Setting
                {
                    Price   = model.Price,
                    ChiefId = newChief.Id
                });

                return(View("Success"));
            }

            ModelState.AddModelError(string.Empty, "Bu kullanıcı adı başka bir hesap tarafından zaten kullanılıyor.");

            return(View(model));
        }
Пример #6
0
 public HttpResponseMessage Create(HttpRequestMessage request, BotViewModel botVm)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (String.IsNullOrEmpty(botVm.UserID))
         {
             response = request.CreateResponse(HttpStatusCode.NotFound);
             return response;
         }
         Bot botDb = new Bot();
         botDb.UpdateBot(botVm);
         var botReturn = _botService.Create(ref botDb);
         try
         {
             // create file bot aiml
             //string pathFolderAIML = ConfigurationManager.AppSettings["AIMLPath"];
             string pathFolderAIML = PathServer.PathAIML;
             string nameFolderAIML = "User_" + botVm.UserID + "_BotID_" + botReturn.ID;
             string pathString = System.IO.Path.Combine(pathFolderAIML, nameFolderAIML);
             System.IO.Directory.CreateDirectory(pathString);
         }
         catch (Exception ex)
         {
         }
         Setting settingDb = new Setting();
         settingDb.BotID = botDb.ID;
         settingDb.Color = "rgb(75, 90, 148);";
         settingDb.UserID = botVm.UserID;
         settingDb.Logo = "assets/images/user_bot.jpg";
         _settingService.Create(settingDb);
         _settingService.Save();
         var reponseData = Mapper.Map <Bot, BotViewModel>(botReturn);
         response = request.CreateResponse(HttpStatusCode.OK, reponseData);
         return response;
     }));
 }
Пример #7
0
 public Setting Create(Setting setting)
 {
     return(_settingService.Create(setting));
 }