Ejemplo n.º 1
0
        public JsonResult AddPartsInfo(VM_PartsInfo partsInfo)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    tblPartsInfo aPartsInfo = new tblPartsInfo();

                    aPartsInfo.PartsName       = partsInfo.PartsName;
                    aPartsInfo.BasePrice       = partsInfo.BasePrice;
                    aPartsInfo.WorkShopId      = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString());
                    aPartsInfo.CreatedBy       = SessionManger.LoggedInUser(Session);
                    aPartsInfo.CreatedDateTime = DateTime.Now;
                    aPartsInfo.EditedBy        = null;
                    aPartsInfo.EditedDateTime  = null;

                    unitOfWork.PartsInfoRepository.Insert(aPartsInfo);
                    unitOfWork.Save();

                    return(Json(new { success = true, successMessage = "Parts Information Added Successfully!" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { success = false, errorMessage = "Fill Up all required filled" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Update(VM_PartsInfo partsInfo)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    tblPartsInfo aPartsInfo = unitOfWork.PartsInfoRepository.GetByID(partsInfo.PartsId);

                    aPartsInfo.PartsName      = partsInfo.PartsName;
                    aPartsInfo.BasePrice      = partsInfo.BasePrice;
                    aPartsInfo.EditedBy       = SessionManger.LoggedInUser(Session);
                    aPartsInfo.EditedDateTime = DateTime.Now;



                    unitOfWork.PartsInfoRepository.Update(aPartsInfo);
                    unitOfWork.Save();

                    return(Json(new { success = true, successMessage = "parts Info update successfully." }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { success = false, errorMessage = "Enter All required Field" }, JsonRequestBehavior.AllowGet));
            }
        }