Пример #1
0
        /// <summary>
        /// Delete the current FacilityDepartment based on the FacilityDepartment ID passed in the FacilityDepartmentModel
        /// </summary>
        /// <param name="id">
        /// The identifier.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult DeleteFacilityDepartment(int id)
        {
            var list = new List <FacilityDepartmentCustomModel>();

            using (var bal = new FacilityDepartmentBal())
            {
                // Get FacilityDepartment model object by current FacilityDepartment ID
                FacilityDepartment model = bal.GetFacilityDepartmentById(id);
                int      userId          = Helpers.GetLoggedInUserId();
                DateTime currentDate     = Helpers.GetInvariantCultureDateTime();
                int      corporateid     = Helpers.GetSysAdminCorporateID();
                int      facilityid      = Helpers.GetSysAdminCorporateID();

                // Check If FacilityDepartment model is not null
                if (model != null)
                {
                    model.ModifiedBy   = userId;
                    model.ModifiedDate = currentDate;
                    model.IsActive     = false;

                    // Update Operation of current FacilityDepartment
                    List <FacilityDepartmentCustomModel> result = bal.SaveFacilityDepartment(model);
                    list = bal.GetFacilityDepartmentList(corporateid, facilityid, true);

                    // return deleted ID of current FacilityDepartment as Json Result to the Ajax Call.
                    return(this.Json(result));
                }
            }

            // Pass the ActionResult with List of FacilityDepartmentViewModel object to Partial View FacilityDepartmentList
            return(this.PartialView(PartialViews.FacilityDepartmentList, list));
        }
Пример #2
0
        /// <summary>
        /// Add New or Update the FacilityDepartment based on if we pass the FacilityDepartment ID in the
        ///     FacilityDepartmentViewModel object.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// returns the newly added or updated ID of FacilityDepartment row
        /// </returns>
        public ActionResult SaveFacilityDepartment(FacilityDepartment model)
        {
            // Initialize the newId variable
            int      userId      = Helpers.GetLoggedInUserId();
            DateTime currentDate = Helpers.GetInvariantCultureDateTime();
            var      list        = new List <FacilityDepartmentCustomModel>();
            int      facilityid  = Helpers.GetDefaultFacilityId();
            int      corporateid = Helpers.GetSysAdminCorporateID();

            // Check if Model is not null
            if (model != null)
            {
                using (var bal = new FacilityDepartmentBal())
                {
                    model.CorporateId    = corporateid;
                    model.FacilityId     = facilityid;
                    model.ExternalValue1 = model.ExternalValue1.Split(':')[1].Replace(")", string.Empty);
                    model.ExternalValue2 = model.ExternalValue2.Split(':')[1].Replace(")", string.Empty);
                    if (model.Id > 0)
                    {
                        model.ModifiedBy   = userId;
                        model.ModifiedDate = currentDate;
                    }
                    else
                    {
                        model.CreatedBy   = userId;
                        model.CreatedDate = currentDate;
                    }

                    // Call the AddFacilityDepartment Method to Add / Update current FacilityDepartment
                    list = bal.SaveFacilityDepartment(model);
                }
            }

            // Pass the ActionResult with List of FacilityDepartmentViewModel object to Partial View FacilityDepartmentList
            return(this.PartialView(PartialViews.FacilityDepartmentList, list));
        }