Exemplo n.º 1
0
 public VoucherViewModel GetAllVouchers()
 {
     var mod = new VoucherViewModel();
     mod.IsValid = true;
     try
     {
         string userName = (string)HttpContext.Current.Session["UserName"]; // (string)Session["UserName"];
         mod.Voucher.VchNo = _alKhairSvc.GetNextVoucherNo(userName);
         mod.Vouchers = _alKhairSvc.GetAllVouchers(AppConstants.SITE_CODE); //.GetViewOfAllVouchers(AppConstants.SITE_CODE, EntityTypeCodes.GFT.ToString());
         mod.GiftTypes = _alKhairSvc.GetViewOfAllGiftTypes(AppConstants.SITE_CODE, EntityTypeCodes.GFT.ToString());
         mod.Donors = _alKhairSvc.GetViewOfAllDonors(AppConstants.SITE_CODE);
     }
     catch (Exception ex)
     {
         mod.IsValid = false;
         mod.Message = ex.Message;
     }
     return mod;
 }
Exemplo n.º 2
0
        public VoucherViewModel ModifyVoucher(VoucherBE mod)
        {
            VoucherViewModel model = new VoucherViewModel();

            try
            {
                DBOperations op = mod.IsActive ? DBOperations.Update : DBOperations.Delete;
                mod.SiteCode = AppConstants.SITE_CODE;
                model.Voucher = mod;
                model.IsValid = model.Validate();
                if (op == DBOperations.Delete || model.IsValid)
                {
                    //_bdmSvc.ModifyEntity(mod);
                    _alKhairSvc.ModifyVoucher(mod);

                    model.FieldId = "VoucherName";
                    model.Voucher = new VoucherBE();
                    model.Vouchers = _alKhairSvc.GetViewOfAllVouchers(AppConstants.SITE_CODE);
                    model.Message = op == DBOperations.Update ? string.Format(AppConstants.CRUD_UPDATE, "Voucher Name") : string.Format(AppConstants.CRUD_DELETE, "Voucher Name");
                }
            }
            catch (Exception ex)
            {
                model.IsValid = false;
                model.Message = ex.Message;
                if (ex.Message.Contains("Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions."))
                    model.Message = "Unable to modify Region Code";
            }
            return model;
        }
Exemplo n.º 3
0
        public VoucherViewModel AddVoucher(VoucherViewModel model)
        {
            try
            {
                model.IsValid = model.Validate();
                if (model.IsValid)
                {
                    //if (_bdmSvc.CityCodeExists(AppConstants.SITE_CODE, model.City.CityCode))
                    //{
                    //    model.FieldId = "cityCode";
                    //    model.Message = string.Format(AppConstants.VALIDATION_ALREADY_EXISTS, "City Code");
                    //    model.IsValid = false;
                    //}

                    //if (model.IsValid)
                    //{
                    model.Voucher.SiteCode = AppConstants.SITE_CODE;
                    model.Voucher.UserName = (string)HttpContext.Current.Session["UserName"];
                    //model.Voucher.EntityTypeCode = EntityTypeCodes.GFT.ToString();
                    _alKhairSvc.AddVoucher(model.Voucher);

                    model.FieldId = "vchNo";
                    model.Voucher = new VoucherBE();
                    string userName = (string)HttpContext.Current.Session["UserName"]; // (string)Session["UserName"];
                    model.Voucher.VchNo = _alKhairSvc.GetNextVoucherNo(userName);

                    model.Vouchers = _alKhairSvc.GetAllVouchers(AppConstants.SITE_CODE); //.GetViewOfAllVouchers(AppConstants.SITE_CODE);
                    model.Message = string.Format(AppConstants.CRUD_CREATE, "Voucher");
                    //}
                }
            }
            catch (Exception ex)
            {
                model.IsValid = false;
                model.Message = ex.Message;
            }

            return model;
        }