public int SaveData(EmployeeVM model)
        {
            var _db = new CodeSampleContext();

            var obj = _db.Employees.FirstOrDefault(x => x.ID == model.ID && x.IsDeleted == false);

            if (obj == null)
            {
                obj           = new Employee();
                obj.IsDeleted = false;
            }

            obj.DepartmentId = model.DepartmentId;
            obj.FirstName    = model.FirstName;
            obj.LastName     = model.LastName;
            obj.Email        = model.Email;
            obj.Mobile       = model.Mobile;
            obj.DOB          = model.DOB;
            obj.Gender       = model.Gender;
            obj.Country      = model.Country;
            obj.State        = model.State;
            obj.City         = model.City;
            obj.ZipCode      = model.ZipCode;
            obj.Address      = model.Address;
            obj.IsActive     = model.IsActive;

            obj.LastActivityBy = model.LastActivityBy;
            obj.LastActivityOn = Helper.GetCurrentDateTime();


            #region Update Section
            if (obj.ID > 0)
            {
                _db.Employees.Attach(obj);
                _db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
            }
            else
            {
                _db.Employees.Add(obj);
            }
            #endregion

            return(_db.SaveChanges() > 0 ? obj.ID : 0);
        }
        public int Remove(int id, int?lastActivityBy)
        {
            var _db = new CodeSampleContext();
            var obj = _db.Employees.FirstOrDefault(x => x.ID == id && x.IsDeleted == false);

            if (obj != null)
            {
                obj.LastActivityBy = lastActivityBy;
                obj.LastActivityOn = Helper.GetCurrentDateTime();
                obj.IsActive       = false;
                obj.IsDeleted      = true;

                _db.Employees.Attach(obj);
                _db.Entry(obj).State = System.Data.Entity.EntityState.Modified;

                return(_db.SaveChanges() > 0 ? obj.ID : 0);
            }
            else
            {
                return(0);
            }
        }