Example #1
0
        public JsonResult Action(VoucherTypeActionModel model)
        {
            bool        result;
            VoucherType objectFirst;
            string      msg = "";

            if (model.Id > 0)
            {
                objectFirst           = service.GetByID(model.Id);
                objectFirst.Id        = model.Id;
                objectFirst.Name      = model.Name;
                objectFirst.AddedById = UserHelperInfo.GetUserId();
                objectFirst.DateTime  = DateTime.Now;
                objectFirst.IP        = UserInfo.IP();
                objectFirst.Agent     = UserInfo.Agent();
                objectFirst.Location  = UserInfo.Location();
                try
                {
                    result = service.Update(objectFirst);
                }
                catch (Exception exc)
                {
                    msg    = exc.Message.ToString();
                    result = false;
                }
            }
            else
            {
                objectFirst = new VoucherType
                {
                    Name      = model.Name,
                    DateTime  = DateTime.Now,
                    AddedById = UserHelperInfo.GetUserId(),
                    IP        = UserInfo.IP(),
                    Agent     = UserInfo.Agent(),
                    Location  = UserInfo.Location(),
                };
                try
                {
                    result = service.Save(objectFirst);
                }
                catch (Exception exc)
                {
                    msg    = exc.Message.ToString();
                    result = false;
                }
            }

            JsonResult jsonResult = new JsonResult
            {
                Data = result ? (new { Success = true, Msg = msg }) : (new { Success = false, Msg = msg })
            };

            return(jsonResult);
        }
Example #2
0
        public ActionResult Delete(int ID)
        {
            VoucherType            objectFirst = service.GetByID(ID);
            VoucherTypeActionModel model       = new VoucherTypeActionModel
            {
                Id   = objectFirst.Id,
                Name = objectFirst.Name
            };

            return(PartialView("_Delete", model));
        }
Example #3
0
        public ActionResult Action(int?ID)
        {
            VoucherTypeActionModel model = new VoucherTypeActionModel();

            if (ID.HasValue)
            {
                VoucherType objectFirst = service.GetByID(ID.Value);
                model.Id   = objectFirst.Id;
                model.Name = objectFirst.Name;
            }
            return(PartialView("_Action", model));
        }
        public JsonResult Action(VoucherTypeActionModel model)
        {
            bool        result;
            VoucherType voucherType = new VoucherType()
            {
                Name       = model.Name,
                AddedById  = UserHelperInfo.GetUserId(),
                IP         = UserInfo.IP(),
                Agent      = UserInfo.Agent(),
                Longitude  = model.Longitude,
                Latitude   = model.Latitude,
                ModifiedOn = DateTimeHelper.Now()
            };
            string msg = "";

            if (model.Id > 0)
            {
                voucherType.Id = model.Id;
                try
                {
                    result = service.Update(voucherType);
                }
                catch (Exception exc)
                {
                    msg    = exc.Message.ToString();
                    result = false;
                }
            }
            else
            {
                try
                {
                    result = service.Save(voucherType);
                }
                catch (Exception exc)
                {
                    msg    = exc.Message.ToString();
                    result = false;
                }
            }

            JsonResult jsonResult = new JsonResult
            {
                Data = result ? (new { Success = true, Msg = msg }) : (new { Success = false, Msg = msg })
            };

            return(jsonResult);
        }