Esempio n. 1
0
        public IHttpActionResult PutDesignation(int id, Designation designation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != designation.Id)
            {
                return(BadRequest());
            }

            db.Entry(designation).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DesignationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public ActionResult ForgetPassword(string EmailID, string UserName)
        {
            bool status = false;

            var account = (from user in db.tblUsers
                           join emp in db.tblEmployees on user.EmployeeId equals emp.EmployeeId
                           where emp.Email == EmailID && user.UserName == UserName
                           select new
            {
                emp.Email,
                emp.EmployeeId
            }).FirstOrDefault();

            if (account != null)
            {
                string resetCode = Guid.NewGuid().ToString();
                SendVerificationLinkEmail(account.Email, resetCode, "ResetPassword");
                var getuser = db.tblUsers.Where(x => x.EmployeeId == account.EmployeeId).FirstOrDefault();
                if (getuser != null)
                {
                    getuser.ResetPasswordCode = resetCode;
                    db.Configuration.ValidateOnSaveEnabled = false;
                    db.SaveChanges();
                    TempData["Success"] = "Password reset link sent to your Email";
                }
            }
            else
            {
                TempData["Error"] = "Account not found";
            }

            return(View());
        }
        public MembershipModel SaveMembership(MembershipModel membershipModel)
        {
            var membership = new Membership
            {
                Name = membershipModel.Name
            };

            _dbContext.Memberships.Add(membership);
            _dbContext.SaveChanges();

            membershipModel.Id = membership.Id;
            return(membershipModel);
        }
Esempio n. 4
0
        public LanguageModel SaveLanguage(LanguageModel languageModel)
        {
            var language = new Language
            {
                Name = languageModel.Name
            };

            _dbContext.Languages.Add(language);
            _dbContext.SaveChanges();

            languageModel.Id = language.Id;
            return(languageModel);
        }
        public LicenseModel SaveLicense(LicenseModel licenseModel)
        {
            var license = new License
            {
                Name = licenseModel.Name
            };

            _dbContext.Licenses.Add(license);
            _dbContext.SaveChanges();

            licenseModel.Id = license.Id;
            return(licenseModel);
        }
Esempio n. 6
0
        public EducationModel SaveEducation(EducationModel educationModel)
        {
            var education = new Education
            {
                Name = educationModel.Name
            };

            _dbContext.Educations.Add(education);
            _dbContext.SaveChanges();

            educationModel.Id = education.Id;
            return(educationModel);
        }
Esempio n. 7
0
        public NationalityModel SaveNationality(NationalityModel nationalityModel)
        {
            var nationality = new Nationality
            {
                Name = nationalityModel.Name
            };

            _dbContext.Nationalities.Add(nationality);
            _dbContext.SaveChanges();

            nationalityModel.Id = nationality.Id;
            return(nationalityModel);
        }
        public Model.CostCenter SaveCostCenter(Model.CostCenter costCenter)
        {
            CostCenter costCenterToSave = new CostCenter
            {
                Description = costCenter.Description,
                Name        = costCenter.Name
            };

            _dbContext.CostCenters.Add(costCenterToSave);
            _dbContext.SaveChanges();

            costCenter.Id = costCenterToSave.Id;
            return(costCenter);
        }
Esempio n. 9
0
        public SkillModel SaveSkill(SkillModel skillModel)
        {
            var skill = new Skill
            {
                Description = skillModel.Description,
                Name        = skillModel.Name
            };

            _dbContext.Skills.Add(skill);
            _dbContext.SaveChanges();

            skillModel.Id = skill.Id;
            return(skillModel);
        }
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.Id)
            {
                return(BadRequest());
            }
            db.Entry(employee.Addresses.ElementAt(0)).State = EntityState.Modified;
            foreach (EmployeesEducationQualification employeeEducationQualification in employee.EmployeesEducationQualifications)
            {
                if (employeeEducationQualification.Id == 0)
                {
                    db.Entry(employeeEducationQualification).State = EntityState.Added;
                }
                else
                {
                    db.Entry(employeeEducationQualification).State = EntityState.Modified;
                }
            }
            db.Entry(employee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public LocationModel SaveLocation(LocationModel locationModel)
        {
            var location = new Location
            {
                Address    = locationModel.Address,
                City       = locationModel.City,
                CountryId  = locationModel.CountryId,
                EeoEnabled = locationModel.EeoEnabled,
                Fax        = locationModel.Fax,
                Name       = locationModel.Name,
                Notes      = locationModel.Notes,
                Phone      = locationModel.Phone,
                State      = locationModel.State,
                TimeZoneId = locationModel.TimeZoneId,
                ZipCode    = locationModel.ZipCode
            };

            _dbContext.Locations.Add(location);
            _dbContext.SaveChanges();

            locationModel.Id = location.Id;
            return(locationModel);
        }
Esempio n. 12
0
 public void Save()
 {
     context.SaveChanges();
 }