public ActionResult Save(SlsDefect slsDefect)
        {
            int companyId = Convert.ToInt32(Session["companyId"]);
            int userId = Convert.ToInt32(Session["userId"]);

            Operation objOperation = new Operation { Success = false };
            if (ModelState.IsValid && slsDefect != null)
            {
                if (slsDefect.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        slsDefect.SecCompanyId = companyId;
                        slsDefect.CreatedBy = userId;
                        slsDefect.CreatedDate = DateTime.Now;
                        //invDamage.InvDamageDetails = null;
                        objOperation = _IDefectEntryService.Save(slsDefect);
                    }
                }
                else
                {

                }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
        public Operation Delete(SlsDefect objSlsDefect)
        {
            Operation objOperation = new Operation { Success = true, OperationId = objSlsDefect.Id };
            _DefectEntryRepository.Delete(objSlsDefect);

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception)
            {

                objOperation.Success = false;
            }
            return objOperation;
        }
        public Operation Save(SlsDefect obj)
        {
            //Operation objOperation = new Operation { Success = true };

            //int Id = _DefectEntryRepository.AddEntity(obj);
            //objOperation.OperationId = Id;

            //try
            //{
            //    _UnitOfWork.Commit();
            //}
            //catch (Exception ex)
            //{
            //    objOperation.Success = false;
            //}

            //return objOperation;
            Operation objOperation = new Operation { Success = true };
            obj.Date = DateTime.Now.Date;
            int Id = _DefectEntryRepository.AddEntity(obj);
            objOperation.OperationId = Id;

            //Detail section.
            if (obj.SlsDefectDetails != null && obj.SlsDefectDetails.Count() > 0)
            {
                new DefectDetailEntryRepository(new DatabaseFactory()).AddEntityList(obj.SlsDefectDetails.ToList());
            }

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception ex)
            {

                objOperation.Success = false;
            }

            return objOperation;
        }