Exemplo n.º 1
0
        public ActionResult GmoIdelAssets_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <GmoIdelAsset> gmoIdelAssets, string userID)
        {
            int _userID    = userID.ToInt();
            var _userInfo  = db.peAppUsers.Where(u => u.ID.Equals(_userID)).Select(u => new { u.Dept, u.LoginName }).FirstOrDefault();
            var results    = new List <GmoIdelAsset>();
            var idelAssets = gmoIdelAssets as IList <GmoIdelAsset> ?? gmoIdelAssets.ToList();

            if (ModelState.IsValid)
            {
                foreach (var gmoIdelAsset in idelAssets)
                {
                    var entity = new GmoIdelAsset
                    {
                        DeptName      = gmoIdelAsset.DeptName,
                        ZicanId       = gmoIdelAsset.ZicanId,
                        ZicanName     = gmoIdelAsset.ZicanName,
                        Pinpai        = gmoIdelAsset.Pinpai,
                        Xinghao       = gmoIdelAsset.Xinghao,
                        CunfangDidian = gmoIdelAsset.CunfangDidian,
                        QidongDate    = gmoIdelAsset.QidongDate,
                        BeginDate     = gmoIdelAsset.BeginDate,
                        Reason        = gmoIdelAsset.Reason,
                        Status        = gmoIdelAsset.Status,
                        Fuzeren       = gmoIdelAsset.Fuzeren,
                        Yuanzhi       = gmoIdelAsset.Yuanzhi,
                        LeijiZhejiu   = gmoIdelAsset.LeijiZhejiu,
                        JingZhi       = gmoIdelAsset.JingZhi,
                        Inputer       = _userInfo.LoginName ?? "",
                        //InputDatetime = DateTime.Now,
                        Modifier       = "",
                        ModifyDatetime = gmoIdelAsset.ModifyDatetime
                    };

                    db.GmoIdelAssets.Add(entity);
                    gmoIdelAsset.Id = entity.Id;
                }
                db.SaveChanges();
            }

            return(Json(idelAssets.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 2
0
        public ActionResult GmoIdelAssets_Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <GmoIdelAsset> gmoIdelAssets)
        {
            var entities = new List <GmoIdelAsset>();

            if (ModelState.IsValid)
            {
                foreach (var gmoIdelAsset in gmoIdelAssets)
                {
                    var entity = new GmoIdelAsset
                    {
                        Id             = gmoIdelAsset.Id,
                        DeptName       = gmoIdelAsset.DeptName,
                        ZicanId        = gmoIdelAsset.ZicanId,
                        ZicanName      = gmoIdelAsset.ZicanName,
                        Pinpai         = gmoIdelAsset.Pinpai,
                        Xinghao        = gmoIdelAsset.Xinghao,
                        CunfangDidian  = gmoIdelAsset.CunfangDidian,
                        QidongDate     = gmoIdelAsset.QidongDate,
                        BeginDate      = gmoIdelAsset.BeginDate,
                        Reason         = gmoIdelAsset.Reason,
                        Status         = gmoIdelAsset.Status,
                        Fuzeren        = gmoIdelAsset.Fuzeren,
                        Yuanzhi        = gmoIdelAsset.Yuanzhi,
                        LeijiZhejiu    = gmoIdelAsset.LeijiZhejiu,
                        JingZhi        = gmoIdelAsset.JingZhi,
                        Inputer        = gmoIdelAsset.Inputer,
                        InputDatetime  = gmoIdelAsset.InputDatetime,
                        Modifier       = gmoIdelAsset.Modifier,
                        ModifyDatetime = gmoIdelAsset.ModifyDatetime
                    };
                    entities.Add(entity);
                    db.GmoIdelAssets.Attach(entity);
                    db.GmoIdelAssets.Remove(entity);
                }
                db.SaveChanges();
            }

            return(Json(entities.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 3
0
        public ActionResult GmoIdelAssets_Update([DataSourceRequest] DataSourceRequest request, GmoIdelAsset gmoIdelAsset, string userID)
        {
            int _userID   = userID.ToInt();
            var _userInfo = db.peAppUsers.Where(u => u.ID.Equals(_userID)).Select(u => new { u.Dept, u.LoginName }).FirstOrDefault();

            if (ModelState.IsValid)
            {
                var entity = new GmoIdelAsset
                {
                    Id            = gmoIdelAsset.Id,
                    DeptName      = gmoIdelAsset.DeptName,
                    ZicanId       = gmoIdelAsset.ZicanId,
                    ZicanName     = gmoIdelAsset.ZicanName,
                    Pinpai        = gmoIdelAsset.Pinpai,
                    Xinghao       = gmoIdelAsset.Xinghao,
                    CunfangDidian = gmoIdelAsset.CunfangDidian,
                    QidongDate    = gmoIdelAsset.QidongDate,
                    BeginDate     = gmoIdelAsset.BeginDate,
                    Reason        = gmoIdelAsset.Reason,
                    Status        = gmoIdelAsset.Status,
                    Fuzeren       = gmoIdelAsset.Fuzeren,
                    Yuanzhi       = gmoIdelAsset.Yuanzhi,
                    LeijiZhejiu   = gmoIdelAsset.LeijiZhejiu,
                    JingZhi       = gmoIdelAsset.JingZhi,
                    Inputer       = gmoIdelAsset.Inputer,
                    //InputDatetime = gmoIdelAsset.InputDatetime,
                    Modifier       = _userInfo.LoginName ?? "",
                    ModifyDatetime = DateTime.Now
                };

                db.GmoIdelAssets.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new[] { gmoIdelAsset }.ToDataSourceResult(request, ModelState)));
        }