Exemplo n.º 1
0
 public JsonResult SaveAccGroup(acc_Group aAccGroup)
 {
     if (ModelState.IsValid)
     {
         try
         {
             //Code
             aAccGroup.OCode           = 1;
             aAccGroup.RestaurantId    = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString());
             aAccGroup.CreatedBy       = SessionManger.LoggedInUser(Session);
             aAccGroup.CreatedDateTime = DateTime.Now;
             aAccGroup.EditedBy        = null;
             aAccGroup.EditedDateTime  = null;
             unitOfWork.AccGroupRepository.Insert(aAccGroup);
             unitOfWork.Save();
             return(Json(new { success = true, successMessage = "Account Group added successfully" }));
         }
         catch (Exception ex)
         {
             return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         return(Json(new { success = false, errorMessage = "Model is not Valid!! Please, Fill up all the fields." }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 2
0
 public JsonResult UpdateAccGroup(acc_Group aAccGroup)
 {
     try
     {
         acc_Group accGroup = unitOfWork.AccGroupRepository.GetByID(aAccGroup.GroupID);
         accGroup.GroupID        = aAccGroup.GroupID;
         accGroup.GroupName      = aAccGroup.GroupName;
         accGroup.GroupCode      = aAccGroup.GroupCode;
         accGroup.NatureID       = aAccGroup.NatureID;
         accGroup.ParentGroupID  = aAccGroup.ParentGroupID;
         accGroup.EditedBy       = SessionManger.LoggedInUser(Session);
         accGroup.EditedDateTime = DateTime.Now;
         unitOfWork.AccGroupRepository.Update(accGroup);
         unitOfWork.Save();
         return(Json(new { success = true, successMessage = "Account Group Edited Successfully." }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception exception)
     {
         return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }