Beispiel #1
0
        public async Task <IActionResult> Create(QuotaViewModel _Quotamodel, string IsEditMode)
        {
            //*-------- Sen to save api
            QuotaType _Quotagetapi = new QuotaType()
            {
                TypeCode    = _Quotamodel.TypeCode,
                Description = _Quotamodel.Description
            };
            var UserCompCode = GetCurrenCompCode();
            var _UserProfile = await _IUserprofileRepository.GetUserProfile(UserCompCode);

            if (ModelState.IsValid)
            {
                if (IsEditMode.Equals("false"))
                {
                    var _Re = ServiceExtension.RestshapExtension.CallRestApiPOST(_Quotagetapi, "http://192.168.10.46/sdapi/sdapi/QuotaTypePost", Getkey());
                    if (_Re.success)
                    {
                        _clientNotification.AddSweetNotification("สำเร็จ",
                                                                 "บันทึกข้อมูลเรียบร้อยแล้ว",
                                                                 NotificationHelper.NotificationType.success);
                    }
                    else
                    {
                        _clientNotification.AddSweetNotification("ผิดพลาด !!",
                                                                 _Re.message,
                                                                 NotificationHelper.NotificationType.error);
                        return(RedirectToAction(nameof(Index)));
                    }
                }
                else
                {
                    QuotaType _Quota = new QuotaType()
                    {
                        TypeCode    = _Quotamodel.TypeCode,
                        Description = _Quotamodel.Description,
                        UpdateBy    = _UserProfile.EmployeeId,
                        Version     = 0,
                        UpdateDate  = ConvertDatetime(DateTime.UtcNow)
                    };

                    var _Re = ServiceExtension.RestshapExtension.CallRestApiPOST(_Quota, "http://192.168.10.46/sdapi/sdapi/QuotaTypePut/" + _Quota.TypeCode, Getkey());
                    if (_Re.success)
                    {
                        _clientNotification.AddSweetNotification("สำเร็จ",
                                                                 "แก้ไขข้อมูลเรียบร้อยแล้ว",
                                                                 NotificationHelper.NotificationType.success);
                    }
                    else
                    {
                        _clientNotification.AddSweetNotification("ผิดพลาด !!",
                                                                 _Re.message,
                                                                 NotificationHelper.NotificationType.error);
                        return(RedirectToAction(nameof(Index)));
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View("Create", _Quotamodel));
        }
Beispiel #2
0
        public IActionResult Create()
        {
            var _Quotamodel = new QuotaViewModel();

            ViewBag.IsEditMode = "false";
            return(View(_Quotamodel));
        }
Beispiel #3
0
        public ActionResult Index()
        {
            QuotaTypes quotaType    = (QuotaTypes)TempData["quotaType"];
            string     currentValue = TempData["currentValue"].ToString();
            string     maxValue     = TempData["maxValue"].ToString();

            string message = string.Empty;

            switch (quotaType)
            {
            case QuotaTypes.Documents:
                message = string.Concat("Przekroczona maksymalna liczba (", maxValue, ") dokumentów.");
                break;

            case QuotaTypes.DocumentCategories:
                message = string.Concat("Przekroczona maksymalna liczba (", maxValue, ") kategorii.");
                break;

            case QuotaTypes.DocumentTypes:
                message = string.Concat("Przekroczona maksymalna liczba (", maxValue, ") typów.");
                break;

            case QuotaTypes.ScansInDocument:
                message = string.Concat("Przekroczona maksymalna liczba (", maxValue, ") skanów w dokumencie.");
                break;

            case QuotaTypes.ScansTotalSize:
                message = string.Concat("Przekroczony maksymalny rozmiar(", maxValue, "MB) skanów w systemie.");
                break;

            case QuotaTypes.Clients:
                message = string.Concat("Przekroczony maksymalny liczba(", maxValue, ") klientów w systemie.");
                break;

            default:
                break;
            }

            QuotaViewModel viewModel = new QuotaViewModel()
            {
                Message = message
            };

            if ((bool)TempData["isAjax"])
            {
                return(PartialView("QuotaInfoControl", viewModel));
            }
            else
            {
                return(View(viewModel));
            }
        }
Beispiel #4
0
        public IActionResult Edit(string Id)
        {
            ViewBag.IsEditMode = "true";
            List <QuotaType> AuthorList = new List <QuotaType> ();
            QuotaViewModel   _Quota     = new QuotaViewModel();
            var Call = ServiceExtension.RestshapExtension.CallRestApiGETEDIT(AuthorList, "http://192.168.10.46/sdapi/sdapi/QuotaTypeGet/" + Id, Getkey());

            foreach (var item in Call)
            {
                _Quota.TypeCode    = item.TypeCode;
                _Quota.Description = item.Description;
            }
            return(View("Create", _Quota));
        }
Beispiel #5
0
 public static bool AddQuota(QuotaViewModel model)
 {
     if (model != null)
     {
         SchoolQuota quota = new SchoolQuota()
         {
             QuotaAssigned = model.Quota,
             SchoolId      = model.SchoolId,
             SessionId     = model.SessionId,
             Year          = model.Year,
             DateCreated   = DateTime.Now,
             CreatedBy     = SessionUser.Name,
             UserId        = SessionUser.UserId
         };
         unitofwork.Quota.Insert(quota);
         unitofwork.Save();
         return(true);
     }
     return(false);
 }
Beispiel #6
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (ValidateInput())
     {
         QuotaViewModel quota = new QuotaViewModel()
         {
             SchoolId  = int.Parse(ddlSchool.SelectedValue),
             SessionId = int.Parse(ddlYear.SelectedValue),
             Year      = ddlYear.SelectedItem.Text,
             Quota     = int.Parse(txtQuota.Value)
         };
         var result = GeneralUtility.AddQuota(quota);
         if (result)
         {
             DropDownManager.ShowPopUp("Quota Successfully Assigned to School");
         }
         else
         {
             DropDownManager.ShowPopUp("Quota Failed to Assign, Try Again");
         }
     }
 }