コード例 #1
0
        public ActionResult Save(SaleBillHeaderViewModel model, bool IsPreviewVoucher)
        {
            if (ModelState.IsValid)
            {
                if (IsPreviewVoucher)
                {
                    var voucherHeader  = this.MapToEntity(model);
                    var voucherdetails = this.ConvertVoucherModelToViewModel(voucherHeader.VoucherHeader.VoucherDetails);
                    return(Json(voucherdetails, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (model.SaleBillHeaderid == 0)
                    {
                        var entity = this.MapToEntity(model);
                        db.SaleBillHeaders.Add(entity);
                        db.SaveChanges();
                    }
                    return(Json(ConfirmationMessages.CreateSuccessConfirmation("Record Saved Successfully")));
                }
            }
            else
            {
                return(View("Create", new SaleBillHeaderViewModel()));
            }

            //return Json("Error Occurred While Saving");
        }
コード例 #2
0
 public ActionResult Save(AccountsViewModel model)
 {
     if (model.AccountId == 0)
     {
         var entity = MapToEntity(model);
         db.Account.Add(entity);
         db.SaveChanges();
     }
     return(Json(ConfirmationMessages.CreateSuccessConfirmation("Record Saved Successfully")));
 }