public Operation Delete(SlsFieldVisit record)
        {
            Operation objOperation = new Operation { Success = true, OperationId = record.Id };
            _repository.Delete(record);

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

                objOperation.Success = false;
            }
            return objOperation;
        }
        public ActionResult SaveFromAndroid(SlsFieldVisit fieldVisit,int cmpId,int userId)
        {
            //var memstream = new MemoryStream();
            //Request.InputStream.Position = 0;
            //Request.InputStream.CopyTo(memstream);
            //memstream.Position = 0;
            //using (StreamReader reader = new StreamReader(memstream))
            //{
            //    var text = reader.ReadToEnd();
            //    Debug.WriteLine(text);
            //}

            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                if (fieldVisit.Id == 0)
                {

                    fieldVisit.RefNo = this.GenerateRefNo(cmpId,userId);
                    fieldVisit.CreatedBy = userId;
                    fieldVisit.CreatedDate = DateTime.Now.Date;
                    fieldVisit.VisitDate = DateTime.Now.Date;
                    SecUser usr = _SecUserService.GetById(userId);
                    var employeeId = (int)usr.HrmEmployeeId.Value;
                    fieldVisit.HrmEmployeeId = employeeId;
                    objOperation = _fieldVisitService.Save(fieldVisit);

                }

            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
        public ActionResult Save(SlsFieldVisit fieldVisit)
        {
            int userId = Convert.ToInt32(Session["userId"]);
            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                if (fieldVisit.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        fieldVisit.RefNo = this.GenerateRefNo();
                        fieldVisit.CreatedBy = userId;

                        fieldVisit.CreatedDate = DateTime.Now.Date;
                        // fieldVisit.FollowupDate = DateTime.Now.Date;
                        fieldVisit.VisitDate = DateTime.Now.Date;
                        SecUser usr = _SecUserService.GetById(userId);
                        var employeeId = (int)usr.HrmEmployeeId.Value;
                        fieldVisit.HrmEmployeeId = employeeId;
                        objOperation = _fieldVisitService.Save(fieldVisit);
                    }
                    else { objOperation.OperationId = -1; }

                }
                else
                {
                    if ((bool)Session["Edit"])
                    {
                        fieldVisit.ModifiedBy = userId;
                        fieldVisit.ModifiedDate = DateTime.Now.Date;
                        objOperation = _fieldVisitService.Update(fieldVisit);
                    }
                    else { objOperation.OperationId = -2; }
                }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
        public Operation Save(SlsFieldVisit record)
        {
            Operation objOperation = new Operation { Success = true };

            long Id = _repository.AddEntity(record);
            objOperation.OperationId = Id;
            try
            {
                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                objOperation.Success = false;
            }
            return objOperation;
        }
 public Operation Update(SlsFieldVisit record)
 {
     throw new NotImplementedException();
 }