Beispiel #1
0
        public ActionResult Create(CoolAppModel model)
        {
            CoolApp coolApp = _coolAppService.GetById(model.Id);

            if (coolApp != null)
            {
                model.Errors.Add(_languageService.GetLocaleString("CoolApp Already Exists"));
                return(Json(model));
            }

            if (_coolAppService.GetAll().Where(k => k.Id == model.Id && k.CoolComId == model.CompanyId).Count() > 0)
            {
                model.Errors.Add(_languageService.GetLocaleString("CoolApp Already Exists"));
                return(Json(model));
            }

            if (ModelState.IsValid)
            {
                coolApp               = new CoolApp();
                coolApp.CoolComId     = model.CompanyId;
                coolApp.CoolCompanyId = model.CoolCompanyId;
                coolApp.AppCode       = model.AppCode;
                _coolAppService.Insert(coolApp);
                model.SuccessMessage = _languageService.GetLocaleString("CoolApp Created");
            }
            else
            {
                model.Errors.Add("Check fields for editing");
            }
            return(Json(model));
        }
Beispiel #2
0
        public ActionResult Create()
        {
            CoolAppModel model = new CoolAppModel();

            model = PrepareCoolAppModel(model, new CoolApp(), true);
            return(View(model));
        }
Beispiel #3
0
        private CoolAppListModel PrepareCoolAppListModel(CoolAppListModel model, List <CoolApp> coolApps)
        {
            foreach (var c in coolApps)
            {
                CoolAppModel ccm = new CoolAppModel();
                ccm = PrepareCoolAppModel(ccm, c);
                model.Items.Add(ccm);
            }

            return(model);
        }
Beispiel #4
0
        public ActionResult Edit(string Id)
        {
            CoolAppModel model    = new CoolAppModel();
            var          coolUser = _coolAppService.GetById(Id);


            if (coolUser == null)
            {
                model.Errors.Add(_languageService.GetLocaleString("CoolApp not found"));
                return(View(model));
            }

            model = PrepareCoolAppModel(model, coolUser, true);
            return(View(model));
        }
Beispiel #5
0
        private CoolAppModel PrepareCoolAppModel(CoolAppModel model, CoolApp coolApp, bool fillAvailableCompanies = false)
        {
            model.Id            = coolApp.Id;
            model.AppCode       = coolApp.AppCode;
            model.CompanyId     = coolApp.CoolComId;
            model.CoolCompanyId = coolApp.CoolCompanyId;
            model.Image         = "<span class=\"avatar avatar-online\"><img src=\"" + _erpManagerSettings.AppPicturePath + coolApp.Id + "\"/></span>";
            if (fillAvailableCompanies)
            {
                model.AvailableCompanies = _coolComService.GetAll().Select(k => new SelectListItem {
                    Text = k.Id, Value = k.Id
                }).ToList();
            }

            return(model);
        }
Beispiel #6
0
        public ActionResult Delete(string Id)
        {
            CoolAppModel model    = new CoolAppModel();
            var          coolUser = _coolAppService.GetById(Id);

            if (coolUser != null)
            {
                _coolAppService.Delete(Id);
            }
            else
            {
                model.Errors.Add(_languageService.GetLocaleString("CoolApp Couldn't found"));
            }

            model.SuccessMessage = _languageService.GetLocaleString("CoolApp Deleted successfully");
            return(Json(model));
        }
Beispiel #7
0
        public ActionResult Edit(CoolAppModel model)
        {
            var coolApp = _coolAppService.GetById(model.Id);

            if (coolApp == null)
            {
                model.Errors.Add(_languageService.GetLocaleString("CoolApp not found"));
                return(Json(model));
            }
            if (ModelState.IsValid)
            {
                coolApp.CoolComId     = model.CompanyId;
                coolApp.CoolCompanyId = model.CoolCompanyId;
                coolApp.AppCode       = model.AppCode;
                _coolAppService.Update(coolApp);

                model.SuccessMessage = _languageService.GetLocaleString("CoolApp Updated");
            }
            else
            {
                model.Errors.Add("Check fields for editing");
            }
            return(Json(model));
        }