Esempio n. 1
0
        public JsonResult DeleteLocationOfMicrochip(LocationOfMicrochip ObjDelete)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.UserAccount.GetUserByID(userId);
                ObjDelete.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.LocationOfMicrochip.Delete(ObjDelete);
                _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));
            }
        }
Esempio n. 2
0
        public void Delete(LocationOfMicrochip ObjDelete)
        {
            var ObjToDelete = _context.LocationOfMicrochips.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.LocationOfMicrochipID == ObjDelete.LocationOfMicrochipID);

            if (ObjToDelete != null)
            {
                _context.LocationOfMicrochips.Remove(ObjToDelete);
            }
        }
Esempio n. 3
0
        public void Update(LocationOfMicrochip ObjUpdate)
        {
            var ObjToUpdate = _context.LocationOfMicrochips.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.LocationOfMicrochipID == ObjUpdate.LocationOfMicrochipID);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.ArabicName  = ObjUpdate.ArabicName;
                ObjToUpdate.EnglishName = ObjUpdate.EnglishName;
            }
        }
Esempio n. 4
0
        public ActionResult SaveLocationOfMicrochip()
        {
            var userId              = User.Identity.GetUserId();
            var UserInfo            = _unitOfWork.UserAccount.GetUserByID(userId);
            LocationOfMicrochip Obj = new LocationOfMicrochip
            {
                LocationOfMicrochipID = _unitOfWork.LocationOfMicrochip.GetMaxSerial(UserInfo.fCompanyId)
            };

            return(PartialView(Obj));
        }
Esempio n. 5
0
        public JsonResult SaveLocationOfMicrochip(LocationOfMicrochip ObjToSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.UserAccount.GetUserByID(userId);
                ObjToSave.LocationOfMicrochipID = _unitOfWork.LocationOfMicrochip.GetMaxSerial(UserInfo.fCompanyId);
                ObjToSave.InsDateTime           = DateTime.Now;
                ObjToSave.InsUserID             = userId;
                ObjToSave.CompanyID             = UserInfo.fCompanyId;
                if (String.IsNullOrEmpty(ObjToSave.EnglishName))
                {
                    ObjToSave.EnglishName = ObjToSave.ArabicName;
                }
                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.LocationOfMicrochip.Add(ObjToSave);
                _unitOfWork.Complete();
                Msg.LastID = _unitOfWork.LocationOfMicrochip.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));
            }
        }
Esempio n. 6
0
 public void Add(LocationOfMicrochip ObjSave)
 {
     _context.LocationOfMicrochips.Add(ObjSave);
 }