コード例 #1
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
 public ActionResult Create(ZoneModels model)
 {
     try
     {
         if (string.IsNullOrEmpty(model.Name))
         {
             ModelState.AddModelError("Name", CurrentUser.GetLanguageTextFromKey("Name field is required"));
             return(View(model));
         }
         string msg    = "";
         bool   result = _factory.InsertOrUpdateZones(model, ref msg);
         if (result)
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             //return RedirectToAction("Create");
             ModelState.AddModelError("Name", _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(msg));
             return(View(model));
         }
     }
     catch (Exception ex)
     {
         _logger.Error("Zone_Create : " + ex);
         return(new HttpStatusCodeResult(400, ex.Message));
     }
 }
コード例 #2
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
 public ZoneModels GetDetail(string id)
 {
     try
     {
         ZoneModels model = _factory.GetListZone(null, id)[0];
         return(model);
     }
     catch (Exception ex)
     {
         _logger.Error("Zones_Detail: " + ex);
         return(null);
     }
 }
コード例 #3
0
ファイル: ZoneFactory.cs プロジェクト: ttcp112/FJ
        public bool InsertOrUpdateZones(ZoneModels model, ref string msg)
        {
            try
            {
                ZoneApiModels paraBody = new ZoneApiModels();
                paraBody.AppKey        = Commons.AppKey;
                paraBody.AppSecret     = Commons.AppSecret;
                paraBody.CreatedUser   = Commons.CreateUser;
                paraBody.RegisterToken = new RegisterTokenModels();

                paraBody.ID      = model.ID;
                paraBody.StoreID = model.StoreID;

                paraBody.Name        = model.Name;
                paraBody.Description = model.Description;
                paraBody.Width       = model.Width;
                paraBody.Height      = model.Height;
                //====================

                var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.CreateOrEditZones, null, paraBody);

                if (result != null)
                {
                    if (result.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        _logger.Error(result.Message);
                        msg = result.Message;
                        msg = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(msg);
                        return(false);
                    }
                }
                else
                {
                    _logger.Error(result);
                    return(false);
                }
            }
            catch (Exception e)
            {
                _logger.Error("Zone_InsertOrUpdate: " + e);
                return(false);
            }
        }
コード例 #4
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
        public ActionResult Edit(ZoneModels model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.StoreID))
                {
                    ModelState.AddModelError("StoreID", CurrentUser.GetLanguageTextFromKey("Please choose Store"));
                }
                if (string.IsNullOrEmpty(model.Name))
                {
                    ModelState.AddModelError("Name", CurrentUser.GetLanguageTextFromKey("Zone Name is required"));
                }

                if (!ModelState.IsValid)
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(PartialView("_Edit", model));
                }

                //====================

                string msg    = "";
                var    result = _factory.InsertOrUpdateZones(model, ref msg);

                if (result)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Height", msg);
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(PartialView("_Edit", model));
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Zone_Edit: " + ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }
コード例 #5
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
 public ActionResult Delete(ZoneModels model)
 {
     try
     {
         string msg    = "";
         var    result = _factory.DeleteZones(model.ID, ref msg);
         if (!result)
         {
             ModelState.AddModelError("Name", msg);
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(PartialView("_Delete", model));
         }
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         _logger.Error("Zones_Delete: " + ex);
         ModelState.AddModelError("Name", CurrentUser.GetLanguageTextFromKey("Have an error when you delete a Zone"));
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(PartialView("_Delete", model));
     }
 }
コード例 #6
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
        public ActionResult Create()
        {
            ZoneModels model = new ZoneModels();

            return(View(model));
        }
コード例 #7
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
        public new PartialViewResult View(string id)
        {
            ZoneModels model = GetDetail(id);

            return(PartialView("_View", model));
        }
コード例 #8
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
        public PartialViewResult Edit(string id)
        {
            ZoneModels model = GetDetail(id);

            return(PartialView("_Edit", model));
        }
コード例 #9
0
ファイル: SZoneController.cs プロジェクト: ttcp112/FJ
        public PartialViewResult Delete(string id)
        {
            ZoneModels model = GetDetail(id);

            return(PartialView("_Delete", model));
        }