示例#1
0
 public JobModel GetJobByEmployeeId(string employeeId)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     JobModel jobModel = new JobModel();
     Job job = new Job();
     AutoMapper.Mapper.Map(jobModel, job);
     job = repo.GetAll().Where(x => x.EmployeeId == employeeId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, jobModel);
     return jobModel;
 }
示例#2
0
 public IHttpActionResult GetTranscationHistoryById(int Id)
 {
     //get transcation history
     TransactionHistoryModel model = transactionHistoryService.GetTransactionHistoryByCartId(Id);
     TransactionHistoryBindingModel bindingModel = new TransactionHistoryBindingModel();
     AutoMapper.Mapper.Map(model, bindingModel);
     //get plan info
     PlanModel planModel = planService.GetPlanById(bindingModel.PlanId);
     bindingModel.PlanName = planModel.Description;
     bindingModel.URFXPaymentTypeString = ((URFXPaymentType)bindingModel.URFXPaymentType).ToString();
     //get job detail
     JobModel jobModel = new JobModel();
     jobModel = jobService.GetJobById(model.JobId);
     bindingModel.JobDescription = jobModel.Description;
     return Ok(bindingModel);
 }
示例#3
0
        public IHttpActionResult Confirm(string employeeId, int jobId)
        {
            try
            {

                //Get job by jobId
                JobModel jobModel = new JobModel();
                jobModel = jobService.GetJobById(jobId);
                jobModel.EmployeeId = employeeId;
                jobModel = jobService.UpadteJob(jobModel);
                ApplicationUser user = UserManager.FindById(employeeId);
                if (user != null)
                {
                    if (user.DeviceType == Utility.Constants.DEVICE_TYPE_ANDROID)
                    {
                        string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.userId=" + employeeId + "&data.jobId=" + jobId + "&data.type=" + Utility.Constants.JOB_ASSING_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_JOBASSIGN + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + user.DeviceToken + "";
                        var response = sendNotificationService.SendNotificationForAndroid(postData);
                    }
                    else if (user.DeviceType == Utility.Constants.DEVICE_TYPE_IOS)
                    {
                        string payload = "{\"aps\":{\"alert\":\"" + "Hi, " + Utility.Constants.MESSAGE_FOR_JOBASSIGN + "" + "\",\"badge\":1,\"sound\":\"default\"},\"JobId\":" + jobId + ",\"userId\":\"" + employeeId + "\",\"type\":\"" + Utility.Constants.JOB_ASSING_TYPE + "\"}";
                        sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
                    }
                }
                return Ok("Confirm");
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
        }
示例#4
0
        public IHttpActionResult GetEmployeeByServiceProviderId(string id, int jobId)
        {
            //get service provider employee mapping 
            List<ServiceProviderEmployeeMappingModel> serviceProviderEmployeeMappingModel = new List<ServiceProviderEmployeeMappingModel>();
            serviceProviderEmployeeMappingModel = serviceProviderEmployeeMappingService.GetEmployeeByServiceProviderId(id);
            //Get employee
            List<EmployeeModel> employeeModel = new List<EmployeeModel>();
            List<EmployeeBindingModel> employeeBindingModel = new List<EmployeeBindingModel>();
            string[] employeeId = serviceProviderEmployeeMappingModel.Select(u => u.EmployeeId.ToString()).ToArray();
            employeeModel = employeeService.GetEmployeeListByServiceProviderId(employeeId);
            AutoMapper.Mapper.Map(employeeModel, employeeBindingModel);
            //get job according to employee
            JobModel jobModel = new JobModel();
            foreach (var item in employeeBindingModel)
            {
                jobModel = jobService.GetJobById(jobId);
                //int count = jobModel.Where(x => JobStatus.Current.ToString().Contains(x.Status.ToString())).Count(); //jobService.GetStatusOfEmployee();
                EmployeeScheduleModel employeeScheduleModel = new EmployeeScheduleModel();
                employeeScheduleModel = employeeScheduleService.GetEmployeesScheduleByEmployeeId(item.EmployeeId).FirstOrDefault();
                JobModel assignedJobModel = new JobModel();
                if (employeeScheduleModel != null)
                {
                    assignedJobModel = jobService.GetJobById(employeeScheduleModel.JobId);
                }

                if (employeeScheduleModel != null)
                {
                    if (jobModel.StartDate > employeeScheduleModel.Start)
                    {
                        if (employeeScheduleModel.Start < jobModel.StartDate && employeeScheduleModel.End > jobModel.StartDate)
                        {
                            //if (assignedJobModel.Status == JobStatus.Current)
                            //{
                            //    item.EmployeeStatus = EmployeeStatus.Working;
                            //}
                            //else
                            //{
                            //    item.EmployeeStatus = EmployeeStatus.Available;
                            //}
                            item.EmployeeStatus = EmployeeStatus.Working;
                        }
                        else
                        {
                            item.EmployeeStatus = EmployeeStatus.Available;
                        }
                    }
                    else
                    {
                        TimeSpan duration = Convert.ToDateTime(employeeScheduleModel.Start) - Convert.ToDateTime(jobModel.StartDate);
                        jobModel.StartDate = Convert.ToDateTime(jobModel.StartDate).AddHours(duration.Hours).AddMinutes(duration.Minutes);
                        if (employeeScheduleModel.Start <= jobModel.StartDate && employeeScheduleModel.Start <= jobModel.EndDate)
                        {
                            //if (assignedJobModel.Status == JobStatus.Current)
                            //{
                            //    item.EmployeeStatus = EmployeeStatus.Working;
                            //}
                            //else
                            //{
                            //    item.EmployeeStatus = EmployeeStatus.Available;
                            //}
                            item.EmployeeStatus = EmployeeStatus.Working;
                        }
                        else
                        {
                            item.EmployeeStatus = EmployeeStatus.Available;
                        }
                    }
                    //if (jobModel.StartDate != employeeScheduleModel.Start && jobModel.EndDate != employeeScheduleModel.End)
                    //{
                    //    item.EmployeeStatus = EmployeeStatus.Available;
                    //}
                    //else
                    //{
                    //    item.EmployeeStatus = EmployeeStatus.Working;
                    //}
                }
                else
                {
                    item.EmployeeStatus = EmployeeStatus.Available;
                }



            }


            return Ok(employeeBindingModel);
        }
示例#5
0
 public JobModel GetJobById(int jobId)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     JobModel jobModel = new JobModel();
     Job job = new Job();
     AutoMapper.Mapper.Map(jobModel, job);
     job = repo.GetAllIncluding("ServiceProvider").Where(x => x.JobId == jobId).OrderByDescending(x=>x.JobId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, jobModel);
     return jobModel;
 }
示例#6
0
        public JobModel UpadteJob(JobModel model)
        {
            //unitOfWork.StartTransaction();
            JobRepository repo = new JobRepository(unitOfWork);
            Job job = new Job();
            job = repo.GetAll().Where(x => x.JobId == model.JobId).FirstOrDefault();
            AutoMapper.Mapper.Map(model, job);
            repo.Update(job);
            //unitOfWork.Commit();
            AutoMapper.Mapper.Map(job, model);

            return model;
        }
示例#7
0
 public IHttpActionResult AdditionalTask(AdditionalTaskModel model)
 {
     JobModel jobModel = new JobModel();
     jobModel = jobService.GetJobById(model.JobId);
     jobModel.AdditionalTaskDescription = model.Description;
     jobModel = jobService.UpadteJob(jobModel);
     return Ok(model);
 }
示例#8
0
 public IHttpActionResult GetJob(int id)
 {
     JobBindingModel jobBindingModel = new JobBindingModel();
     JobModel jobModel = new JobModel();
     AutoMapper.Mapper.Map(jobBindingModel, jobModel);
     jobModel = jobService.GetJobById(id);
     AutoMapper.Mapper.Map(jobModel, jobBindingModel);
     jobBindingModel.EmployeeModel = employeeServices.GetEmployeeById(jobBindingModel.EmployeeId);
     return Ok(jobBindingModel);
 }
示例#9
0
        public IHttpActionResult AcceptJob(string userId, int jobId)
        {
            JobBindingModel jobBindingModel = new JobBindingModel();
            try
            {
                //Get job by jobId
                JobModel jobModel = new JobModel();
                AutoMapper.Mapper.Map(jobBindingModel, jobModel);
                jobModel = jobService.GetJobById(jobId);
                jobModel.EmployeeId = userId;
                jobModel.Status = JobStatus.Current;
                jobModel = jobService.UpadteJob(jobModel);
                AutoMapper.Mapper.Map(jobModel, jobBindingModel);
                //get job service mapping
                List<JobServiceMappingModel> jobServiceMappingModel = new List<JobServiceMappingModel>();
                jobServiceMappingModel = jobServiceMappingService.GetJobServiceMappingListByJobId(jobBindingModel.JobId);
                foreach (var item in jobServiceMappingModel)
                {
                    SubServiceModel subServiceModel = new SubServiceModel();
                    subServiceModel = subServicesService.GetSubServiceById(item.ServiceId);
                    item.ServiceName = subServiceModel.Description;
                }
                //get job service picture mapping
                List<JobServicePictureMappingModel> jobServicePictureMappingModel = new List<JobServicePictureMappingModel>();
                jobServicePictureMappingModel = jobServicePictruesMappingService.GetJobServicePictureMapping();
                jobBindingModel.JobServiceMappings = jobServiceMappingModel.Where(j => j.JobId == jobBindingModel.JobId).ToList();

                jobServiceMappingModel.ForEach(x =>
                {
                    x.JobServicePictureMappings = jobServicePictureMappingModel.Where(j => j.JobServiceMappingId == x.JobServiceMappingId).ToList();
                });
                //get client inforamtion

                //Get Client Name
                ClientModel clientModel = new ClientModel();
                clientModel = clientService.GetClientById(jobBindingModel.ClientId);
                jobBindingModel.ClientModel = clientModel;
                ApplicationUser user = UserManager.FindById(jobModel.ClientId);
                if (user != null)
                {
                    if (user.DeviceType == Utility.Constants.DEVICE_TYPE_ANDROID)
                    {
                        string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.userId=" + userId + "&data.jobId=" + jobId + "&data.type=" + Utility.Constants.JOB_ACCEPT_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_JOB_ACCEPT + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + user.DeviceToken + "";
                        var response = sendNotificationService.SendNotificationForAndroid(postData);
                    }
                    else if (user.DeviceType == Utility.Constants.DEVICE_TYPE_IOS)
                    {
                        string payload = "{\"aps\":{\"alert\":\"" + "Hi, " + Utility.Constants.MESSAGE_FOR_JOB_ACCEPT + "" + "\",\"badge\":1,\"sound\":\"default\"},\"JobId\":" + jobId + ",\"userId\":\"" + userId + "\",\"type\":\"" + Utility.Constants.JOB_ACCEPT_TYPE + "\"}";
                        sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
                    }
                }





            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }

            return Json(jobBindingModel);
        }
示例#10
0
        public IHttpActionResult CompleteTask(string userId, int jobId)
        {
            JobBindingModel jobBindingModel = new JobBindingModel();
            try
            {
                
                //Get job by jobId
                JobModel jobModel = new JobModel();
                AutoMapper.Mapper.Map(jobBindingModel, jobModel);
                jobModel = jobService.GetJobById(jobId);
                jobModel.Status = JobStatus.Completed;
                jobModel = jobService.UpadteJob(jobModel);
                AutoMapper.Mapper.Map(jobModel, jobBindingModel);
                //Get employee schedule by jobid and delete
                EmployeeScheduleModel employeeScheduleModel = new EmployeeScheduleModel();
                employeeScheduleModel = employeeScheduleService.GetEmployeesScheduleByJobId(jobId);
                employeeScheduleService.DeleteEmployeeSchedule(employeeScheduleModel.Id);
                ApplicationUser user = UserManager.FindById(jobModel.ClientId);
                if (user != null)
                {
                    if (user.DeviceType == Utility.Constants.DEVICE_TYPE_ANDROID)
                    {
                        string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.userId=" + userId + "&data.jobId=" + jobId + "&data.type=" + Utility.Constants.JOB_COMPLETED_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_JOB_COMPLETED + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + user.DeviceToken + "";
                        var response = sendNotificationService.SendNotificationForAndroid(postData);
                    }
                    else
                    {
                        string payload = "{\"aps\":{\"alert\":\"" + "Hi, " + Utility.Constants.MESSAGE_FOR_JOB_COMPLETED + "" + "\",\"badge\":1,\"sound\":\"default\"},\"JobId\":" + jobId + ",\"userId\":\"" + userId + "\",\"type\":\"" + Utility.Constants.JOB_COMPLETED_TYPE + "\"}";
                        sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
                    }
                }

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
            return Json(jobBindingModel);
        }
示例#11
0
        public async Task<IHttpActionResult> CreateJob()
        {
            //using (var dataContext = new URFXDbContext())
            //{
            //    TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
            //    {
            TaskModel taskModel = new TaskModel();
            JobModel jobModel = new JobModel();
            try
            {
                if (!Request.Content.IsMimeMultipartContent())
                {
                    throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
                }

                var root = HttpContext.Current.Server.MapPath(Utility.Constants.BASE_FILE_UPLOAD_PATH);
                Directory.CreateDirectory(root);
                var provider = new MultipartFormDataStreamProvider(root);
                var resultModel = await Request.Content.ReadAsMultipartAsync(provider);
                if (resultModel.FormData["model"] == null)
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                var result = resultModel.FormData["model"];
                var model = result.Substring(1, result.Length - 2);
                List<JobBindingModel> JobBindingModelList = new List<JobBindingModel>();

                taskModel = JsonConvert.DeserializeObject<TaskModel>(model);
                List<JobModel> jobModelList = new List<JobModel>();
                AutoMapper.Mapper.Map(JobBindingModelList, jobModelList);
                string fileName;
                if (taskModel.StartDate >= DateTime.UtcNow)
                {
                    //Check for individual
                    ServiceProviderModel serviceProviderModel = new ServiceProviderModel();
                    serviceProviderModel = serviceProviderService.GetServiceProviderById(taskModel.ServiceProviderId);
                    if (serviceProviderModel.ServiceProviderType == ServiceProviderType.Individual)
                    {
                        jobModel.EmployeeId = taskModel.ServiceProviderId;
                    }
                    try
                    {
                        //set status and details of job
                        jobModel.Status = JobStatus.New;
                        //jobModel.CreatedDate = DateTime.UtcNow;
                        jobModel.StartDate = taskModel.StartDate;
                        jobModel.EndDate = taskModel.EndDate;
                        jobModel.Description = taskModel.Description;
                        jobModel.ServiceProviderId = taskModel.ServiceProviderId;
                        jobModel.ClientId = taskModel.ClientId;
                        jobModel.Quantity = taskModel.Quantity;
                        jobModel.Comments = taskModel.Comments;
                        jobModel.JobAddress = taskModel.JobAddress;
                        jobModel.Latitude = taskModel.Latitude;
                        jobModel.Longitude = taskModel.Longitude;
                        jobModel.Cost = taskModel.Cost;
                        //save job
                        jobModel = jobService.SaveJob(jobModel);
                        //Get transcation history for job
                        //TransactionHistoryModel historyModel = new TransactionHistoryModel();
                        //historyModel = transactionHistoryService.FindTransactionHistoryByMerchantRegrence(taskModel.MerchantReference);
                        //historyModel.JobId = jobModel.JobId;
                        //transactionHistoryService.UpdateTransactionHistory(historyModel);
                        //Job service Mapping
                        JobServiceMappingModel jobServiceMappingModel = new JobServiceMappingModel();
                        JobServicePictureMappingModel jobServicePictureMappingModel = new JobServicePictureMappingModel();
                        taskModel.SubTaskList.ForEach(x =>
                        {
                            jobServiceMappingModel.Quantity = x.Quantity;
                            jobServiceMappingModel.JobId = jobModel.JobId;
                            jobServiceMappingModel.Comments = x.Comments;
                            jobServiceMappingModel.ServiceId = x.ServiceId;
                            jobServiceMappingModel.Description = x.Description;
                            jobServiceMappingModel = jobServiceMappingService.SaveJobServiceMapping(jobServiceMappingModel);
                            jobServicePictureMappingModel.JobServiceMappingId = jobServiceMappingModel.JobServiceMappingId;
                            if (HttpContext.Current.Request.Files != null)
                            {
                                for (var i = 0; i < HttpContext.Current.Request.Files.Count; i++)
                                {
                                    var file = HttpContext.Current.Request.Files[i];
                                    fileName = file.FileName;
                                    var splittedFileName = fileName.Split('$');
                                    if (splittedFileName[0] == x.Description)
                                    {
                                        file.SaveAs(Path.Combine(root, Utility.Constants.JOB_SERVICE_IMAGES_PATH, splittedFileName[1]));
                                        jobServicePictureMappingModel.ImagePath = splittedFileName[1];
                                        jobServicePictureMappingModel = jobServicePictruesMappingService.SaveJobServicePictureMapping(jobServicePictureMappingModel);
                                    }
                                }
                            }

                        });
                        //  transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        //   transaction.Dispose();
                        Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                        return BadRequest(ex.Message);
                    }

                }
                else
                {
                    return BadRequest("Job date is not valid");
                }
            }
            
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
        
            //    }
            //}
            return Ok(jobModel);
        }
示例#12
0
 public IHttpActionResult GetJobByJobId(Int32 jobId)
 {
     JobBindingModel jobBindingModel = new JobBindingModel();
     JobModel jobModel = new JobModel();
     AutoMapper.Mapper.Map(jobBindingModel, jobModel);
     jobModel = jobService.GetJobById(jobId);
     AutoMapper.Mapper.Map(jobModel, jobBindingModel);
     //Get Client Name
     ClientModel clientModel = new ClientModel();
     clientModel = clientService.GetClientById(jobBindingModel.ClientId);
     jobBindingModel.ClientName = clientModel.FirstName;
     //Get service City
     UserLocationModel userLocationModel = new UserLocationModel();
     userLocationModel = userLocationService.FindLocationById(jobBindingModel.ClientId);
     if (jobBindingModel.JobAddress == null || jobBindingModel.JobAddress == "")
     {
         jobBindingModel.JobAddress = userLocationModel.Address;
     }
     
     //Get serviceMapping
     JobServiceMappingModel jobServiceMappingModel = new JobServiceMappingModel();
     jobServiceMappingModel = jobServiceMappingService.GetJobServiceMappingByJobId(jobId);
     //get service name
     SubServiceModel subServiceModel = new SubServiceModel();
     subServiceModel = subServicesService.GetSubServiceById(jobServiceMappingModel.ServiceId);
     jobBindingModel.ServiceName = subServiceModel.Description;
     //get service picture mapping
     List<JobServicePictureMappingModel> jobServicePictureMappingModel = new List<JobServicePictureMappingModel>();
     jobServicePictureMappingModel = jobServicePictruesMappingService.GetJobServicePictureMappingByJobServiceMappingId(jobServiceMappingModel.JobServiceMappingId);
     jobServiceMappingModel.JobServicePictureMappings = jobServicePictureMappingModel;
     jobBindingModel.JobServiceMapping = jobServiceMappingModel;
     jobBindingModel.EmployeeModel = employeeServices.GetEmployeeById(jobBindingModel.EmployeeId);
     jobBindingModel.RatingModel = ratingService.GetRatingListByJobId(jobBindingModel.JobId);
     return Ok(jobBindingModel);
 }
示例#13
0
 public IHttpActionResult PostJob(JobBindingModel model)
 {
     JobModel job = new JobModel();
     if (!ModelState.IsValid)
     {
         return BadRequest(ModelState);
     }
     AutoMapper.Mapper.Map(model, job);
     job = jobService.SaveJob(job);
     AutoMapper.Mapper.Map(job, model);
     return Ok(model);
 }
示例#14
0
        public ResponseMessage Paging(PagingModel model)
        {
            ResponseMessage responseMessage = new ResponseMessage();
            List<TransactionHistoryModel> transactionHistoryModel = new List<TransactionHistoryModel>();
            transactionHistoryModel = transactionHistoryService.Paging(model);
            responseMessage.totalRecords = transactionHistoryModel.Count();
            transactionHistoryModel = transactionHistoryModel.OrderBy(x => x.CustomerEmail).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList();
            transactionHistoryModel.ForEach(x => {
                JobModel jobModel = new JobModel();
                ServiceProviderModel serviceProviderModel = new ServiceProviderModel();
                if (x.JobId > 0)
                {

                    jobModel = jobService.GetJobById(x.JobId);
                }
                serviceProviderModel = serviceProviderService.GetServiceProviderById(jobModel.ServiceProviderId);
                x.ServiceProviderName = serviceProviderModel.CompanyName;
            });
            responseMessage.data = transactionHistoryModel;

            return responseMessage;
        }
示例#15
0
 public JobModel SaveJob(JobModel model)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     Job job = new Job();
     AutoMapper.Mapper.Map(model, job);
     repo.Insert(job);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, model);
     return model;
 }
示例#16
0
        public IHttpActionResult ReturnSucceesCallback(TransactionHistoryModel model)
        {
            try
            {
                //string headers = string.Empty;
                //foreach (var head in Request.Content.Headers)
                //{
                //    headers += "Key : " + head.Key + " , Value : " + head.Value;
                //}

                //string parameters = string.Empty;

                //foreach (var param in HttpContext.Current.Request.Params)
                //{
                var merchantRefrence = model.MerchantReference;
                TransactionHistoryModel historyModel = new TransactionHistoryModel();
                historyModel = transactionHistoryService.FindTransactionHistoryByMerchantRegrence(merchantRefrence);
                historyModel.Status = model.Status;
                historyModel.ResponseMessage = model.ResponseMessage;
                historyModel.Eci = model.Eci;
                historyModel.CardNumber = model.CardNumber;
                historyModel.FortId = model.FortId;
                historyModel.ResponseCode = model.ResponseCode;
                historyModel.CustomerEmail = model.CustomerEmail;
                historyModel.CustomerIp = model.CustomerIp;
                //historyModel.Amount = model.Amount;
                historyModel.Command = model.Command;
                historyModel.PaymentOption = model.PaymentOption;
                historyModel.ExpiryDate = model.ExpiryDate;
                historyModel.Signature = model.Signature;
                if (historyModel.URFXPaymentType == URFXPaymentType.PlanPayment)
                {

                    if (historyModel.Status == Utility.Constants.SUCCESS_STATUS)
                    {

                        var startDate = DateTime.Now;
                        UserPlanModel userPlanModel = new UserPlanModel();
                        userPlanModel.PlanId = historyModel.PlanId;
                        userPlanModel.UserId = historyModel.UserId;
                        userPlanModel.NumberOfTeams = historyModel.NumberOfTeams;
                        userPlanModel.CreatedDate = startDate;
                        userPlanModel.ExpiredDate = startDate.AddDays(30);
                        bool planExist = userPlanService.CheckExistanceOfUserPlan(userPlanModel.UserId);
                        if (!planExist)
                        {
                            userPlanModel = userPlanService.InsertUserPlan(userPlanModel);

                        }
                        transactionHistoryService.UpdateTransactionHistory(historyModel);
                        //parameters += "Key : " + param + " , value:" + HttpContext.Current.Request.Params[param.ToString()];
                    }
                    else
                    {
                        transactionHistoryService.UpdateTransactionHistory(historyModel);
                    }
                }
                else if(historyModel.URFXPaymentType == URFXPaymentType.JobPayment)
                {
                    ApplicationUser user = UserManager.FindById(historyModel.UserId);
                    transactionHistoryService.UpdateTransactionHistory(historyModel);
                    JobModel jobModel = new JobModel();
                    if (historyModel.Status == Utility.Constants.SUCCESS_STATUS)
                    {

                        jobModel = jobService.GetJobById(historyModel.JobId);
                        jobModel.IsPaid = true;
                        jobModel.CreatedDate = DateTime.UtcNow;
                        jobService.UpadteJob(jobModel);
                    }

                    if (user.DeviceType == Utility.Constants.DEVICE_TYPE_ANDROID)
                    {
                        string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.userId=" + historyModel.UserId + "&data.jobId=" + historyModel.JobId + "&data.type=" + Utility.Constants.JOB_CREATED_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_JOB_CREATED + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + user.DeviceToken + "";
                        var response = sendNotificationService.SendNotificationForAndroid(postData);
                    }
                    else if (user.DeviceType == Utility.Constants.DEVICE_TYPE_IOS)
                    {
                        string payload = "{\"aps\":{\"alert\":\"" + "Hi, " + Utility.Constants.MESSAGE_FOR_JOB_CREATED + "" + "\",\"badge\":1,\"sound\":\"default\"},\"JobId\":" + historyModel.JobId + ",\"userId\":\"" + historyModel.UserId + "\",\"type\":\"" + Utility.Constants.JOB_CREATED_TYPE + "\"}";
                        sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
                    }
                }
                else
                {
                    ApplicationUser user = UserManager.FindById(historyModel.UserId);
                    transactionHistoryService.UpdateTransactionHistory(historyModel);
                    if (user.DeviceType == Utility.Constants.DEVICE_TYPE_ANDROID)
                    {
                        string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.userId=" + historyModel.UserId + "&data.jobId=" + historyModel.JobId + "&data.type=" + Utility.Constants.ADD_ADDITIONAL_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_ADD_ADDITIONAL + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + user.DeviceToken + "";
                        var response = sendNotificationService.SendNotificationForAndroid(postData);
                    }
                    else if (user.DeviceType == Utility.Constants.DEVICE_TYPE_IOS)
                    {
                        string payload = "{\"aps\":{\"alert\":\"" + "Hi, " + Utility.Constants.MESSAGE_FOR_ADD_ADDITIONAL + "" + "\",\"badge\":1,\"sound\":\"default\"},\"JobId\":" + historyModel.JobId + ",\"userId\":\"" + historyModel.UserId + "\",\"type\":\"" + Utility.Constants.ADD_ADDITIONAL_TYPE + "\"}";
                        sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
                    }
                }
                // parameters += "Key : " + param + " , value:" + HttpContext.Current.Request.Params[param.ToString()];
                // }

                // System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("~/ExceptionFile.txt"), headers + parameters);

                return Ok(historyModel);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                System.IO.File.WriteAllText(HttpContext.Current.Server.MapPath("~/ExceptionFile.txt"), ex.Message);
                return Ok();
            }
        }
示例#17
0
        public IHttpActionResult GetComplaintByServiceProviderId(string serviceProviderId)
        {
            List<ComplaintBindingModel> complaintBindingModel = new List<ComplaintBindingModel>();
            List<ComplaintModel> complaintModel = new List<ComplaintModel>();
               // AutoMapper.Mapper.Map(jobBindingModel, jobModel);
            complaintModel = complaintService.GetComplaintListByServiceProviderId(serviceProviderId);
            AutoMapper.Mapper.Map(complaintModel, complaintBindingModel);
            EmployeeModel employeeModel = new EmployeeModel();
            ClientModel clientModel = new ClientModel();
            ServiceProviderModel ServiceProviderModel = new ServiceProviderModel();
            JobModel jobModel = new JobModel();
            complaintBindingModel.ForEach(x => {
                jobModel = jobService.GetJobById(x.JobId);
                employeeModel = employeeService.GetEmployeeById(x.EmployeeId);
                x.EmployeeName = employeeModel.FirstName;
                clientModel = clientService.GetClientById(x.ClientId);
                x.ClientName = clientModel.FirstName;
                ServiceProviderModel = serviceProviderService.GetServiceProviderById(x.ServiceProviderId);
                x.ServiceProviderName = ServiceProviderModel.CompanyName;
                x.JobAddress = jobModel.JobAddress;
                x.JobDescription = jobModel.Description;
                x.Description = x.Description;
                ApplicationUser user = UserManager.FindById(x.ClientId);
                if (user != null)
                {
                    x.ClientPhoneNumber = user.PhoneNumber;
                }

            });
            return Ok(complaintBindingModel);
        }