Example #1
0
 /// <summary>
 /// Method to add the Entity in the database By Id.
 /// </summary>
 /// <param name="deptTimmingId">The Holiday Planner Id.</param>
 /// <returns>
 /// The <see cref="DeptTimming" />.
 /// </returns>
 public DeptTimming GetDeptTimmingById(int?deptTimmingId)
 {
     using (var rep = UnitOfWork.DeptTimmingRepository)
     {
         DeptTimming model = rep.Where(x => x.DeptTimmingId == deptTimmingId).FirstOrDefault();
         return(model);
     }
 }
        /// <summary>
        /// Reset the DeptTimming View Model and pass it to DeptTimmingAddEdit Partial View.
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult" />.
        /// </returns>
        public ActionResult ResetDeptTimmingForm()
        {
            // Intialize the new object of DeptTimming ViewModel
            var deptTimmingViewModel = new DeptTimming();

            // Pass the View Model as DeptTimmingViewModel to PartialView DeptTimmingAddEdit just to update the AddEdit partial view.
            return(PartialView(PartialViews.DeptTimmingAddEdit, deptTimmingViewModel));
        }
        /// <summary>
        /// Get the details of the current DeptTimming in the view model by ID
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult GetDeptTimming(int id)
        {
            using (var bal = new DeptTimmingBal())
            {
                // Call the AddDeptTimming Method to Add / Update current DeptTimming
                DeptTimming currentDeptTimming = bal.GetDeptTimmingById(id);

                // Pass the ActionResult with the current DeptTimmingViewModel object as model to PartialView DeptTimmingAddEdit
                return(PartialView(PartialViews.DeptTimmingAddEdit, currentDeptTimming));
            }
        }
Example #4
0
        /// <summary>
        /// Method to add/Update the Entity in the database.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int SaveDeptTimming(DeptTimming model)
        {
            using (DeptTimmingRepository rep = UnitOfWork.DeptTimmingRepository)
            {
                if (model.DeptTimmingId > 0)
                {
                    rep.UpdateEntity(model, model.DeptTimmingId);
                }
                else
                {
                    rep.Create(model);
                }

                return(model.DeptTimmingId);
            }
        }
        /// <summary>
        /// Add New or Update the DeptTimming based on if we pass the DeptTimming ID in the DeptTimmingViewModel
        ///     object.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// returns the newly added or updated ID of DeptTimming row
        /// </returns>
        public ActionResult SaveDeptTimming(DeptTimming model)
        {
            // Initialize the newId variable
            int newId  = -1;
            int userId = Helpers.GetLoggedInUserId();

            // Check if Model is not null
            if (model != null)
            {
                using (var bal = new DeptTimmingBal())
                {
                    if (model.DeptTimmingId > 0)
                    {
                        // model.ModifiedBy = userId;
                        // model.ModifiedDate = Helpers.GetInvariantCultureDateTime();
                    }

                    // Call the AddDeptTimming Method to Add / Update current DeptTimming
                    newId = bal.SaveDeptTimming(model);
                }
            }

            return(Json(newId));
        }