예제 #1
0
        public string Post(AgencyModel agencyModel)
        {
            string success = "ERROR: ";

            try
            {
                using (GetaJobContext db = new GetaJobContext())
                {
                    JobCompany jobCompany = new JobCompany()
                    {
                        Id             = Guid.NewGuid().ToString(),
                        CompanyTypeRef = "AGE",
                        CompanyName    = agencyModel.CompanyName,
                        CompanyAddress = agencyModel.CompanyAddress,
                        CompanyZip     = agencyModel.CompanyZip,
                        Email          = agencyModel.Email,
                        OfficePhone    = agencyModel.Phone,
                        Website        = agencyModel.Website
                    };
                    db.JobCompanies.Add(jobCompany);
                    db.SaveChanges();

                    Agency agency = new Agency();
                    agency.Id        = Guid.NewGuid().ToString();
                    agency.CompanyId = jobCompany.Id;

                    db.Agencies.Add(agency);
                    db.SaveChanges();
                    success = agency.Id;
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #2
0
        public string Put(AgencyModel agencyModel)
        {
            string success = "";

            try
            {
                using (GetaJobContext db = new GetaJobContext())
                {
                    Agency agency = db.Agencies.Where(a => a.Id == agencyModel.Id).FirstOrDefault();

                    JobCompany jobCompany = db.JobCompanies.Where(j => j.Id == agency.CompanyId).FirstOrDefault();
                    jobCompany.CompanyName    = agencyModel.CompanyName;
                    jobCompany.CompanyAddress = agencyModel.CompanyAddress;
                    jobCompany.Email          = agencyModel.Email;
                    jobCompany.OfficePhone    = agencyModel.Phone;
                    jobCompany.CompanyZip     = agencyModel.CompanyZip;
                    jobCompany.Website        = agencyModel.Website;;

                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #3
0
        public string Post(AgentModel agentModel)
        {
            string success = "ERROR: ";

            try
            {
                using (GetaJobContext db = new GetaJobContext())
                {
                    Person person = new Person()
                    {
                        Id          = Guid.NewGuid().ToString(),
                        FName       = agentModel.FName,
                        LName       = agentModel.LName,
                        CellPhone   = agentModel.Cell,
                        OfficePhone = agentModel.Phone,
                        Email       = agentModel.Email
                    };
                    db.People.Add(person);

                    Agent agent = new Agent()
                    {
                        Id       = Guid.NewGuid().ToString(),
                        PersonId = person.Id,
                        AgencyId = agentModel.AgencyId
                    };

                    db.Agents.Add(agent);
                    db.SaveChanges();
                    success = agent.Id;
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #4
0
        public string Put(AgentModel agentModel)
        {
            string success = "";

            try
            {
                using (GetaJobContext db = new GetaJobContext())
                {
                    Agent agent = db.Agents.Where(a => a.Id == agentModel.Id).FirstOrDefault();
                    //agent.AgencyId

                    Person person = db.People.Where(p => p.Id == agent.PersonId).FirstOrDefault();
                    person.FName       = agentModel.FName;
                    person.LName       = agentModel.LName;
                    person.CellPhone   = agentModel.Cell;
                    person.OfficePhone = agentModel.Phone;
                    person.Email       = agentModel.Email;

                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #5
0
        public string Post(JobListingModel newJobListing)
        {
            string success = "ERROR: ";

            try
            {
                JobListing dbJobListing = new JobListing();
                dbJobListing.Id                = Guid.NewGuid().ToString();
                dbJobListing.JobSearchId       = newJobListing.JobSearchId;
                dbJobListing.PostedDate        = DateTime.Parse(newJobListing.PostedDate);
                dbJobListing.JobTitle          = newJobListing.JobTitle;
                dbJobListing.AgentId           = newJobListing.AgentId;
                dbJobListing.TargetCompanyId   = newJobListing.TargetCompanyId;
                dbJobListing.Comments          = newJobListing.Comments;
                dbJobListing.Rate              = newJobListing.Rate;
                dbJobListing.Distance          = newJobListing.Distance;
                dbJobListing.JobLocation       = newJobListing.Location;
                dbJobListing.ListingStatusRef  = newJobListing.Status;
                dbJobListing.EmploymentTypeRef = newJobListing.EmploymentType;
                dbJobListing.ListingSourceRef  = newJobListing.ListingSource;
                dbJobListing.DesirabilityRef   = newJobListing.Desirability;
                dbJobListing.FitnessRef        = newJobListing.Fit;

                using (GetaJobContext db = new GetaJobContext())
                {
                    db.JobListings.Add(dbJobListing);
                    db.SaveChanges();
                    success = dbJobListing.Id.ToString();
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #6
0
        public string Put(JobSearchModel searchModel)
        {
            string success = "";

            try
            {
                using (GetaJobContext db = new GetaJobContext())
                {
                    JobSearch dbJobSearch = db.JobSearches.Where(j => j.Id == searchModel.Id).FirstOrDefault();
                    if (dbJobSearch != null)
                    {
                        dbJobSearch.Initiated = DateTime.Parse(searchModel.Initiated);
                        if (searchModel.Abandoned != null)
                        {
                            dbJobSearch.Abandoned = DateTime.Parse(searchModel.Abandoned);
                        }
                        dbJobSearch.SearchName = searchModel.SearchName;
                        db.SaveChanges();
                        success = "ok";
                    }
                    else
                    {
                        success = "Id: " + searchModel.Id + "  not found";
                    }
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #7
0
        public string Put(JobRefModel refModel)
        {
            string success = "";

            try
            {
                using (var db = new GetaJobContext())
                {
                    JobRef @ref = db.JobRefs.Where(r => r.RefCode == refModel.RefCode).First();
                    @ref.RefDescription = refModel.RefDescription;
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = ex.Message; }
            return(success);
        }
예제 #8
0
        public string Put(JobSkillModel editedSkill)
        {
            string success = "";

            try
            {
                using (GetaJobContext db = new GetaJobContext())
                {
                    var dbSkill = db.JobSkills.Where(j => j.Id == editedSkill.Id).FirstOrDefault();
                    dbSkill.SkillName   = editedSkill.Name;
                    dbSkill.SkillType   = editedSkill.Category;
                    dbSkill.Narrative   = editedSkill.Narrative;
                    dbSkill.Proficiency = editedSkill.Proficiency;
                    dbSkill.SortOrder   = editedSkill.FontSize;
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #9
0
        public string Post(JobSearchModel searchModel)
        {
            string success = "ERROR: ";

            try
            {
                var jobSearch = new JobSearch();
                jobSearch.Id         = Guid.NewGuid().ToString();
                jobSearch.PersonId   = searchModel.PersonId;
                jobSearch.SearchName = searchModel.SearchName;
                jobSearch.Initiated  = DateTime.Parse(searchModel.Initiated);

                using (GetaJobContext db = new GetaJobContext())
                {
                    db.JobSearches.Add(jobSearch);
                    db.SaveChanges();
                    success = jobSearch.Id.ToString();
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #10
0
        public JobRefModel Post(JobRefModel refModel)
        {
            try
            {
                using (var db = new GetaJobContext())
                {
                    var @ref = new JobRef();
                    @ref.RefType        = refModel.RefType;
                    @ref.RefCode        = GetUniqueRefCode(refModel.RefDescription, db);
                    @ref.RefDescription = refModel.RefDescription;

                    db.JobRefs.Add(@ref);
                    db.SaveChanges();
                    refModel.RefCode = @ref.RefCode;
                    refModel.Success = "ok";
                }
            }
            catch (Exception ex)
            {
                refModel.Success = ex.Message;
            }
            return(refModel);
        }
예제 #11
0
        public string Put(JobListingModel editJobListing)
        {
            string success = "";

            try
            {
                using (GetaJobContext db = new GetaJobContext())
                {
                    JobListing dbJobListing = db.JobListings.Where(j => j.Id == editJobListing.Id).FirstOrDefault();
                    if (dbJobListing != null)
                    {
                        dbJobListing.PostedDate        = DateTime.Parse(editJobListing.PostedDate);
                        dbJobListing.JobLocation       = editJobListing.Location;
                        dbJobListing.JobTitle          = editJobListing.JobTitle;
                        dbJobListing.AgentId           = editJobListing.AgentId;
                        dbJobListing.TargetCompanyId   = editJobListing.TargetCompanyId;
                        dbJobListing.Comments          = editJobListing.Comments;
                        dbJobListing.ListingStatusRef  = editJobListing.Status;
                        dbJobListing.Rate              = editJobListing.Rate;
                        dbJobListing.EmploymentTypeRef = editJobListing.EmploymentType;
                        dbJobListing.Distance          = editJobListing.Distance;
                        dbJobListing.ListingSourceRef  = editJobListing.ListingSource;
                        dbJobListing.DesirabilityRef   = editJobListing.Desirability;
                        dbJobListing.FitnessRef        = editJobListing.Fit;

                        db.SaveChanges();
                        success = "ok";
                    }
                    else
                    {
                        success = "Id: " + editJobListing.Id + "  not found";
                    }
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
예제 #12
0
        public string Post(JobSkillModel newSkill)
        {
            string success = "";

            try
            {
                var dbSkill = new JobSkill();
                dbSkill.Id          = Guid.NewGuid().ToString();
                dbSkill.Narrative   = newSkill.Narrative;
                dbSkill.SkillName   = newSkill.Name;
                dbSkill.Proficiency = newSkill.Proficiency;
                dbSkill.SortOrder   = newSkill.FontSize;
                dbSkill.SkillType   = newSkill.Category;

                using (GetaJobContext db = new GetaJobContext())
                {
                    db.JobSkills.Add(dbSkill);
                    db.SaveChanges();
                    success = dbSkill.Id;
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }