예제 #1
0
        public void Delete(AssetSite ObjDelete)
        {
            var ObjToDelete = _context.AssetSites.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.SiteID == ObjDelete.SiteID);

            if (ObjToDelete != null)
            {
                _context.AssetSites.Remove(ObjToDelete);
            }
        }
예제 #2
0
        public void Update(AssetSite ObjUpdate)
        {
            var ObjToUpdate = _context.AssetSites.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.SiteID == ObjUpdate.SiteID);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.SiteName    = ObjUpdate.SiteName;
                ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime;
                ObjToUpdate.InsUserID   = ObjUpdate.InsUserID;
            }
        }
예제 #3
0
        public ActionResult AddNew()
        {
            var       userId   = User.Identity.GetUserId();
            var       UserInfo = _unitOfWork.User.GetMyInfo(userId);
            AssetSite Obj      = new AssetSite
            {
                SiteID = _unitOfWork.AssetSite.GetMaxSerial(UserInfo.fCompanyId)
            };

            return(PartialView(Obj));
        }
예제 #4
0
        public JsonResult SaveAssetSite(AssetSite ObjSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);
                ObjSave.SiteID      = _unitOfWork.AssetSite.GetMaxSerial(UserInfo.fCompanyId);
                ObjSave.InsDateTime = DateTime.Now;
                ObjSave.InsUserID   = userId;
                ObjSave.CompanyID   = UserInfo.fCompanyId;

                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }

                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                _unitOfWork.AssetSite.Add(ObjSave);
                _unitOfWork.Complete();
                Msg.LastID = _unitOfWork.AssetSite.GetMaxSerial(UserInfo.fCompanyId).ToString();
                Msg.Code   = 1;
                Msg.Msg    = Resources.Resource.AddedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
 public void Add(AssetSite ObjSave)
 {
     _context.AssetSites.Add(ObjSave);
 }