public static void AcceptJobProposal(CustomJobHistory job, string contractorId) { using (var dbcontext = new KaamShaamEntities()) { try { var dbjob = dbcontext.Jobs.FirstOrDefault(j => j.Id == job.JobId); if (dbjob != null) { var jhistory = dbjob.JobHistories.ToList(); foreach (var history in jhistory) { if (history.ContractorId == job.ContractorId) { history.JobStatus = (int)Commons.Enums.JobHistoryStatus.Continue; history.Feedback = "Job started with continue status"; } else { dbcontext.JobHistories.Remove(history); } } dbcontext.SaveChanges(); } var conractUser = UserServices.GetUserById(contractorId); KaamShaam.Services.EmailService.SendEmail(conractUser.Email, "Job Assignment", "You have been assigned a new job '" + dbjob.JobTitle + "'. Visit https://kamsham.pk"); KaamShaam.Services.EmailService.SendSms(conractUser.Mobile, "Your proposal for job has been accepted at https://kamsham.pk"); } catch (Exception dfdf) { } } }
public static void ApplyJob(CustomJobHistory job, string contractorId) { using (var dbcontext = new KaamShaamEntities()) { try { dbcontext.JobHistories.Add(new JobHistory { Feedback = "empty", JobStartDate = DateTime.Now, JobEndDate = DateTime.Now, ContractorId = contractorId, PurposalText = job.PurposalText, JobId = job.JobId, JobStatus = (int)KaamShaam.Commons.Enums.JobHistoryStatus.Applying, }); dbcontext.SaveChanges(); var jobobj = JobService.GetJobById(job.JobId); var posterUser = UserServices.GetUserById(job.PostedById); KaamShaam.Services.EmailService.SendEmail(posterUser.Email, "Job Activity", "There is a new job proposal on your job '" + jobobj.JobTitle + "'. Visit https://kamsham.pk"); KaamShaam.Services.EmailService.SendSms(posterUser.Mobile, "New proposal at your job posted at https://kamsham.pk"); } catch (Exception dfdf) { } } }
public static void CancelJob(CustomJobHistory job, string contractorId) { using (var dbcontext = new KaamShaamEntities()) { try { var jobHistory = dbcontext.JobHistories.FirstOrDefault( ojb => ojb.ContractorId == contractorId && ojb.JobId == job.JobId); if (jobHistory != null) { dbcontext.JobHistories.Remove(jobHistory); dbcontext.SaveChanges(); } } catch (Exception dfdf) { } } }