Esempio n. 1
0
        /// <summary>
        /// Add New or Update the DashboardRemark based on if we pass the DashboardRemark ID in the DashboardRemarkViewModel object.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>
        /// returns the newly added or updated ID of DashboardRemark row
        /// </returns>
        public ActionResult SaveDashboardRemark(DashboardRemark model)
        {
            var userId      = Helpers.GetLoggedInUserId();
            var currentDate = Helpers.GetInvariantCultureDateTime();
            var list        = new List <DashboardRemarkCustomModel>();

            //Check if Model is not null
            if (model != null)
            {
                using (var bal = new DashboardRemarkBal())
                {
                    model.CorporateId = Helpers.GetSysAdminCorporateID();
                    model.IsActive    = true;
                    if (model.Id == 0)
                    {
                        model.CreatedBy   = userId;
                        model.CreatedDate = currentDate;
                    }

                    //Call the AddDashboardRemark Method to Add / Update current DashboardRemark
                    list = bal.SaveDashboardRemark(model);
                }
            }
            //Pass the ActionResult with List of DashboardRemarkViewModel object to Partial View DashboardRemarkList
            return(PartialView(PartialViews.DashboardRemarkList, list));
        }
        /// <summary>
        /// Method to add/Update the Entity in the database.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public List <DashboardRemarkCustomModel> SaveDashboardRemark(DashboardRemark model)
        {
            using (var rep = UnitOfWork.DashboardRemarkRepository)
            {
                if (model.Id > 0)
                {
                    var current = rep.GetSingle(model.Id);
                    model.CreatedBy   = current.CreatedBy;
                    model.CreatedDate = current.CreatedDate;
                    rep.UpdateEntity(model, model.Id);
                }
                else
                {
                    rep.Create(model);
                }

                var currentId = model.Id;
                var list      = GetDashboardRemarkList(Convert.ToInt32(model.CorporateId));
                return(list);
            }
        }