コード例 #1
0
        public void Delete(DetailsOfOwnership ObjDelete)
        {
            var ObjToDelete = _context.DetailsOfOwnerships.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.OwnerID == ObjDelete.OwnerID);

            if (ObjToDelete != null)
            {
                _context.DetailsOfOwnerships.Remove(ObjToDelete);
            }
        }
コード例 #2
0
        public JsonResult SaveDetailsOfOwnership(DetailsOfOwnershipSearchFilterVM ObjToSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.UserAccount.GetUserByID(userId);
                var SavDetailsOfOwnership = new DetailsOfOwnership();
                ObjToSave.OwnerID     = _unitOfWork.DetailsOfOwnership.GetMaxSerial(UserInfo.fCompanyId);
                ObjToSave.InsDateTime = DateTime.Now;
                ObjToSave.InsUserID   = userId;
                ObjToSave.CompanyID   = UserInfo.fCompanyId;

                SavDetailsOfOwnership.OwnerID     = ObjToSave.OwnerID;
                SavDetailsOfOwnership.CityID      = ObjToSave.CityID;
                SavDetailsOfOwnership.CountryID   = ObjToSave.CountryID;
                SavDetailsOfOwnership.FirstName   = ObjToSave.FirstName;
                SavDetailsOfOwnership.Surname     = ObjToSave.Surname;
                SavDetailsOfOwnership.Telephone   = ObjToSave.Telephone;
                SavDetailsOfOwnership.PosCode     = ObjToSave.PosCode;
                SavDetailsOfOwnership.Address     = ObjToSave.Address;
                SavDetailsOfOwnership.InsDateTime = ObjToSave.InsDateTime;
                SavDetailsOfOwnership.InsUserID   = ObjToSave.InsUserID;
                SavDetailsOfOwnership.CompanyID   = ObjToSave.CompanyID;

                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.DetailsOfOwnership.Add(SavDetailsOfOwnership);
                _unitOfWork.Complete();
                Msg.LastID = _unitOfWork.DetailsOfOwnership.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));
            }
        }
コード例 #3
0
        public void Update(DetailsOfOwnership ObjUpdate)
        {
            var ObjToUpdate = _context.DetailsOfOwnerships.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.OwnerID == ObjUpdate.OwnerID);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.Surname   = ObjUpdate.Surname;
                ObjToUpdate.FirstName = ObjUpdate.FirstName;
                ObjToUpdate.CountryID = ObjUpdate.CountryID;
                ObjToUpdate.CityID    = ObjUpdate.CityID;
                ObjToUpdate.Telephone = ObjUpdate.Telephone;
                ObjToUpdate.PosCode   = ObjUpdate.PosCode;
                ObjToUpdate.Address   = ObjUpdate.Address;
            }
        }
コード例 #4
0
        public JsonResult DeleteDetailsOfOwnership(DetailsOfOwnershipSearchFilterVM ObjDelete)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.UserAccount.GetUserByID(userId);
                var DeleteDetailsOfOwnership = new DetailsOfOwnership();
                ObjDelete.CompanyID = UserInfo.fCompanyId;
                DeleteDetailsOfOwnership.CompanyID = ObjDelete.CompanyID;
                DeleteDetailsOfOwnership.OwnerID   = ObjDelete.OwnerID;
                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.DetailsOfOwnership.Delete(DeleteDetailsOfOwnership);
                _unitOfWork.Complete();
                Msg.Code = 1;
                Msg.Msg  = Resources.Resource.DeletedSuccessfully;
                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(DetailsOfOwnership ObjSave)
 {
     _context.DetailsOfOwnerships.Add(ObjSave);
 }