コード例 #1
0
        public ActionResult BulkUpdate([Bind(Include = "Id,ConcurrencyKey,T_Name,T_Description")] T_Refusal t_refusal, FormCollection collection, string UrlReferrer)
        {
            var bulkIds   = collection["BulkUpdate"].Split(',').ToList();
            var chkUpdate = collection["chkUpdate"];

            if (!string.IsNullOrEmpty(chkUpdate))
            {
                bool customsave_hasissues = false;
                foreach (var id in bulkIds.Where(p => p != string.Empty))
                {
                    long      objId  = long.Parse(id);
                    T_Refusal target = db.T_Refusals.Find(objId);
                    target.setDateTimeToClientTime();
                    EntityCopy.CopyValuesForSameObjectType(t_refusal, target, chkUpdate);
                    customsave_hasissues = false;
                    CheckBeforeSave(target, "BulkUpdate");
                    if (ValidateModel(target) && !CustomSaveOnEdit(target, out customsave_hasissues, "BulkUpdate"))
                    {
                        db.Entry(target).State = EntityState.Modified;
                        try
                        {
                            db.SaveChanges();
                        }
                        catch { }
                    }
                }
            }
            RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_refusal, "BulkUpdate", "");

            if (customRedirectAction != null)
            {
                return(customRedirectAction);
            }
            if (!string.IsNullOrEmpty(UrlReferrer))
            {
                return(Redirect(UrlReferrer));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }