コード例 #1
0
 public UserLocationModel FindLocationByUserAndCityId(string userId,int cityId)
 {
     //unitOfWork.StartTransaction();
     UserLocationModel locationModel = new UserLocationModel();
     UserLocationRepository repo = new UserLocationRepository(unitOfWork);
     UserLocation userLocation = new UserLocation();
     userLocation = repo.GetAll(x => x.UserId == userId && x.CityId==cityId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(userLocation, locationModel);
     return locationModel;
 }
コード例 #2
0
        public async Task<IHttpActionResult> UpdateServiceProviderAsIndividual()
        {

            try
            {
                //var userAgent = HttpContext.Current.Request.UserAgent;
                //var deviceType = HttpContext.Current.Request.Headers.GetValues("device_type");
                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"];
                EmployeeBindingModel employeeBindingModel = new EmployeeBindingModel();
                //var model = result.Substring(1, result.Length - 2);
                employeeBindingModel = JsonConvert.DeserializeObject<EmployeeBindingModel>(result);
                //AutoMapper.Mapper.Map(employeeBindingModel, clientModel);
                //var count = resultModel.FormData.Count;

                //employeeBindingModel.EmployeeId = resultModel.FormData[0];
                //employeeBindingModel.FirstName = resultModel.FormData[1];
                //employeeBindingModel.LastName = resultModel.FormData[2];
                //employeeBindingModel.Description = resultModel.FormData[3];
                //employeeBindingModel.CityId = Convert.ToInt32(resultModel.FormData[4]);
                //employeeBindingModel.DistrictId = Convert.ToInt32(resultModel.FormData[5]);
                //employeeBindingModel.CarTypeId = Convert.ToInt32(resultModel.FormData[6]);
                //employeeBindingModel.LicensePlateNumber = resultModel.FormData[7];

                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }

                else
                {
                    try
                    {
                        EmployeeModel employeeModelForCheckRecord = new EmployeeModel();
                        employeeModelForCheckRecord = employeeService.GetEmployeeById(employeeBindingModel.EmployeeId);

                        if (resultModel.FileData.Count > 0)
                        {
                            string fileName;

                            if (HttpContext.Current.Request.Files != null)
                            {
                                for (var i = 0; i < resultModel.FileData.Count; i++)
                                {
                                    var file = HttpContext.Current.Request.Files[i];
                                    fileName = file.FileName;


                                    if (i == 0)
                                    {

                                        file.SaveAs(Path.Combine(root, Utility.Constants.EMPLOYEE_PROFILE_PATH, fileName));
                                        employeeBindingModel.ProfileImage = fileName;
                                    }
                                    else
                                    {
                                        file.SaveAs(Path.Combine(root, Utility.Constants.NATIONAL_ID_PATH, fileName));
                                        employeeBindingModel.NationalIdAndIqamaNumber = fileName;
                                    }

                                }

                            }


                        }
                        if (employeeBindingModel.ProfileImage == null)
                        {
                            employeeBindingModel.ProfileImage = employeeModelForCheckRecord.ProfileImage;
                        }
                        if (employeeBindingModel.NationalIdAndIqamaNumber == null)
                        {
                            employeeBindingModel.NationalIdAndIqamaNumber = employeeModelForCheckRecord.NationalIdAndIqamaNumber;
                        }

                        //Update employee
                        EmployeeModel employeeModelEntity = new EmployeeModel();
                        AutoMapper.Mapper.Map(employeeBindingModel, employeeModelEntity);
                        employeeModelEntity = employeeService.UpadteEmployee(employeeModelEntity);
                        AutoMapper.Mapper.Map(employeeModelEntity, employeeBindingModel);
                        //Add Car type for Employee
                        CarEmployeeMappingModel carEmployeeMappingModel = new CarEmployeeMappingModel();
                        carEmployeeMappingModel.CarTypeId = employeeBindingModel.CarTypeId;
                        carEmployeeMappingModel.EmployeeId = employeeBindingModel.EmployeeId;
                        carEmployeeMappingModel = carEmployeeMappingService.SaveCarEmployeeMapping(carEmployeeMappingModel);
                        //save location for employee

                        UserLocationModel locationModel = new UserLocationModel();
                        locationModel.UserId = employeeBindingModel.EmployeeId;
                        locationModel.CityId = employeeBindingModel.CityId;
                        locationModel.DistrictId = 1;
                        userLocationService.InsertUserLocation(locationModel);
                        //locationModel = userLocationService.FindLocationById(employeeBindingModel.EmployeeId);
                        //if (locationModel.UserLocationId != 0)
                        //{
                        //    userLocationService.UpadteUserLocation(locationModel);
                        //}


                        var user = await UserManager.FindByIdAsync(employeeBindingModel.EmployeeId);
                        if (user.Email != employeeBindingModel.Email)
                        {
                            IdentityResult userResult = await UserManager.UpdateAsync(user);
                        }
                    }
                    catch (Exception ex)
                    {
                        Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                        return BadRequest(ex.Message);
                    }

                }

                return Json(employeeBindingModel);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
        }
コード例 #3
0
        public IHttpActionResult MyJobs(string userId, string type)
        {
            List<JobBindingModel> jobBindingModel = new List<JobBindingModel>();
            try
            {
                //get job according to user id
                List<JobModel> jobModel = new List<JobModel>();
                JobStatus jobStatus = (JobStatus)Enum.Parse(typeof(JobStatus), type);
                jobModel = jobService.GetJobsByEmployeeId(userId, jobStatus);
                AutoMapper.Mapper.Map(jobModel, jobBindingModel);
                //get job service mapping
                List<JobServiceMappingModel> jobServiceMappingModel = new List<JobServiceMappingModel>();
                string[] jobIds = jobBindingModel.Select(u => u.JobId.ToString()).ToArray();
                jobServiceMappingModel = jobServiceMappingService.GetJobServiceMappingByJobIds(jobIds);
                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.ForEach(x =>
                {
                    x.JobServiceMappings = jobServiceMappingModel.Where(j => j.JobId == x.JobId).ToList();
                });
                jobServiceMappingModel.ForEach(x =>
                {
                    x.JobServicePictureMappings = jobServicePictureMappingModel.Where(j => j.JobServiceMappingId == x.JobServiceMappingId).ToList();
                });
                //get client inforamtion
                jobBindingModel.ForEach(x =>
                {
                    //Get Client Name
                    ClientModel clientModel = new ClientModel();
                    clientModel = clientService.GetClientById(x.ClientId);
                    ApplicationUser user = UserManager.FindById(clientModel.ClientId);
                    if (user != null)
                    {
                        clientModel.PhoneNumber = user.PhoneNumber;
                    }
                    x.ClientModel = clientModel;
                    userLocationModel = userLocationService.FindLocationById(x.ClientId);
                    if (x.JobAddress == null || x.JobAddress == "")
                    {
                        x.JobAddress = userLocationModel.Address;
                        x.Latitude = userLocationModel.Latitude;
                        x.Longitude = userLocationModel.Latitude;
                    }


                });

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
            return Ok(jobBindingModel);
        }
コード例 #4
0
        public async Task<IHttpActionResult> PutEmployee()
        {

            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 model = resultModel.FormData["model"];

                EmployeeBindingModel employeeBindingModel = new EmployeeBindingModel();
                employeeBindingModel = JsonConvert.DeserializeObject<EmployeeBindingModel>(model);

                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }

                else
                {

                    EmployeeModel employeeModelForCheckRecord = new EmployeeModel();
                    employeeModelForCheckRecord = employeeService.GetEmployeeById(employeeBindingModel.EmployeeId);

                    if (resultModel.FileData.Count > 0)
                    {
                        string fileName;

                        if (HttpContext.Current.Request.Files != null)
                        {
                            for (var i = 0; i < resultModel.FileData.Count; i++)
                            {
                                var file = HttpContext.Current.Request.Files[i];
                                fileName = file.FileName;


                                if (i == 0)
                                {

                                    file.SaveAs(Path.Combine(root, Utility.Constants.EMPLOYEE_PROFILE_PATH, fileName));
                                    employeeBindingModel.ProfileImage = fileName;
                                }
                                else
                                {
                                    file.SaveAs(Path.Combine(root, Utility.Constants.NATIONAL_ID_PATH, fileName));
                                    employeeBindingModel.NationalIdAndIqamaNumber = fileName;
                                }

                            }

                        }


                    }
                    if (employeeBindingModel.ProfileImage == null)
                    {
                        employeeBindingModel.ProfileImage = employeeModelForCheckRecord.ProfileImage;
                    }
                    if (employeeBindingModel.NationalIdAndIqamaNumber == null)
                    {
                        employeeBindingModel.NationalIdAndIqamaNumber = employeeModelForCheckRecord.NationalIdAndIqamaNumber;
                    }
                    //if (employeeBindingModel.IqamaNumber == null)
                    //{
                    //    employeeBindingModel.IqamaNumber = employeeModelForCheckRecord.IqamaNumber;
                    //}
                    try
                    {
                        //Update employee
                        EmployeeModel employeeModelEntity = new EmployeeModel();
                        AutoMapper.Mapper.Map(employeeBindingModel, employeeModelEntity);
                        employeeModelEntity = employeeService.UpadteEmployee(employeeModelEntity);
                        AutoMapper.Mapper.Map(employeeModelEntity, employeeBindingModel);
                        //Add Car type for Employee
                        if (employeeBindingModel.CarTypeId != 0)
                        {
                            CarEmployeeMappingModel carEmployeeMappingModel = new CarEmployeeMappingModel();
                            carEmployeeMappingModel.CarTypeId = employeeBindingModel.CarTypeId;
                            carEmployeeMappingModel.EmployeeId = employeeBindingModel.EmployeeId;
                            CarEmployeeMappingModel carEmployeeMappingModelCheck = new CarEmployeeMappingModel();
                            carEmployeeMappingModelCheck = carEmployeeMappingService.GetCarEmployeeMappingByEmployeeId(carEmployeeMappingModel.EmployeeId);
                            carEmployeeMappingModelCheck.CarTypeId = employeeBindingModel.CarTypeId;
                            carEmployeeMappingModelCheck.EmployeeId = employeeBindingModel.EmployeeId;
                            if (carEmployeeMappingModelCheck.CarEmployeeMappingId == 0)
                            {
                                carEmployeeMappingModel = carEmployeeMappingService.SaveCarEmployeeMapping(carEmployeeMappingModelCheck);
                            }
                            else
                            {
                                carEmployeeMappingModel = carEmployeeMappingService.UpadteCarEmployeeMapping(carEmployeeMappingModelCheck);
                            }
                        }


                        //save location for employee
                        var location = resultModel.FormData["LocationModel"];
                        UserLocationModel locationModel = new UserLocationModel();
                        UserLocationModel userlocationModel = new UserLocationModel();
                        locationModel = JsonConvert.DeserializeObject<UserLocationModel>(location);
                        locationModel.UserId = employeeBindingModel.EmployeeId;
                        locationModel.DistrictId = 1;
                        bool Exists;
                        Exists = userLocationService.CheckExistance(locationModel.UserId);
                        if (!Exists && locationModel.CityId != 0)
                        {
                            userLocationService.InsertUserLocation(locationModel);
                        }
                        else if (Exists)
                        {
                            userlocationModel = userLocationService.FindLocationById(locationModel.UserId);
                            locationModel.UserLocationId = userlocationModel.UserLocationId;
                            userLocationService.UpadteUserLocation(locationModel);
                        }
                        //check service provider as individual and update service provider
                        IndividualBindingModel individualBindingModel = new IndividualBindingModel();
                        RegisterServiceProviderBindingModel serviceProviderBindingModel = new RegisterServiceProviderBindingModel();
                        ServiceProviderModel serviceProvider = new ServiceProviderModel();
                        serviceProvider = serviceProviderService.GetServiceProviderById(employeeBindingModel.EmployeeId);
                        if (serviceProvider != null && serviceProvider.ServiceProviderType == ServiceProviderType.Individual)
                        {

                            serviceProvider.CompanyLogoPath = employeeBindingModel.ProfileImage;
                            serviceProvider.RegistrationCertificatePath = employeeBindingModel.NationalIdAndIqamaNumber;
                            serviceProvider.Description = employeeBindingModel.Description;

                            serviceProvider = serviceProviderService.UpadteServiceProvider(serviceProvider);
                        }
                        var user = await UserManager.FindByIdAsync(employeeBindingModel.EmployeeId);
                        if (user != null)
                        {
                            if (user.Email != employeeBindingModel.Email || user.PhoneNumber != employeeBindingModel.PhoneNumber)
                            {
                                user.Email = employeeBindingModel.Email;
                                user.PhoneNumber = employeeBindingModel.PhoneNumber;
                                IdentityResult result = await UserManager.UpdateAsync(user);
                            }
                        }

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

                }

                return Ok();
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
        }
コード例 #5
0
 public IHttpActionResult UpdateEmployeeLocation(UserLocationBindingModel model)
 {
     try
     {
         UserLocationModel userLocationModel = new UserLocationModel();
         userLocationModel = userLocationService.FindUserLocationById(model.UserId);
         model.UserLocationId = userLocationModel.UserLocationId;
         model.CityId = userLocationModel.CityId;
         model.DistrictId = userLocationModel.DistrictId;
         AutoMapper.Mapper.Map(model, userLocationModel);
         userLocationModel = userLocationService.UpadteUserLocation(userLocationModel);
         AutoMapper.Mapper.Map(userLocationModel, model);
         ApplicationUser user = UserManager.FindById(model.UserId);
         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.Latitude=" + model.Latitude + "&data.Longitude=" + model.Longitude + "&data.type=" + Utility.Constants.TRACKING_TYPE + "&data.message=" + Utility.Constants.MESSAGE_FOR_TRACKING + "&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_TRACKING + "" + "\",\"badge\":1,\"sound\":\"default\"},\"Latitude\":" + model.Latitude + ",\"Longitude\":\"" + model.Longitude + "\",\"type\":\"" + Utility.Constants.TRACKING_TYPE + "\"}";
                 sendNotificationService.SendNotificationForIOS(user.DeviceToken, payload);
             }
         }
         return Json(model);
     }
     catch (Exception ex)
     {
         Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
         return BadRequest(ex.Message);
     }
 }
コード例 #6
0
 public IHttpActionResult GetEmployee(string id)
 {
     //Get employee
     EmployeeModel employeeModel = new EmployeeModel();
     EmployeeBindingModel employeeBindingModel = new EmployeeBindingModel();
     List<JobModel> jobModel = new List<JobModel>();
     List<JobBindingModel> jobBindingModel = new List<JobBindingModel>();
     employeeModel = employeeService.GetEmployeeById(id);
     AutoMapper.Mapper.Map(employeeModel, employeeBindingModel);
     //Get Details of employee from user table
     var Email = UserManager.FindById(id) != null ? UserManager.FindById(id).Email : "";
     var PhoneNumber = UserManager.FindById(id) != null ? UserManager.FindById(id).PhoneNumber : "";
     //Get Car Type of employee
     CarEmployeeMappingModel carEmployeeMappingModel = new CarEmployeeMappingModel();
     carEmployeeMappingModel = carEmployeeMappingService.GetCarEmployeeMappingByEmployeeId(id);
     //Get Location of employee
     userLocationModel = userLocationService.FindLocationById(id);
     employeeBindingModel.UserLocationModel = userLocationModel;
     employeeBindingModel.CarTypeId = carEmployeeMappingModel.CarTypeId;
     employeeBindingModel.Email = Email;
     employeeBindingModel.PhoneNumber = PhoneNumber;
     //Get rating for employee
     jobModel = jobService.GetJobListByEmployeeId(id);
     AutoMapper.Mapper.Map(jobModel, jobBindingModel);
     List<RatingModel> ratingModel = new List<RatingModel>();
     ratingModel = ratingService.GetAllRatings();
     jobBindingModel.ForEach(x =>
     {
         x.RatingModel = ratingModel.Where(j => j.JobId == x.JobId).ToList();
     });
     employeeBindingModel.JobBindingModel = jobBindingModel;
     var serviceProvider = serviceProviderService.GetServiceProviderById(id);
     if (serviceProvider != null)
     {
         employeeBindingModel.model = serviceProvider;
     }
     return Json(employeeBindingModel);
 }
コード例 #7
0
ファイル: JobsController.cs プロジェクト: codedive/MyDemo1
 // GET: api/Jobs
 public List<JobBindingModel> GetJob()
 {
     List<JobBindingModel> jobBindingModel = new List<JobBindingModel>();
     List<JobModel> jobModel = new List<JobModel>();
     AutoMapper.Mapper.Map(jobBindingModel, jobModel);
     jobModel = jobService.GetAllJobs();
     AutoMapper.Mapper.Map(jobModel, jobBindingModel);
     jobBindingModel.ForEach(x =>
     {
         //Get Client Name
         ClientModel clientModel = new ClientModel();
         clientModel = clientService.GetClientById(x.ClientId);
         x.ClientName = clientModel.FirstName;
         //Get service City
         UserLocationModel userLocationModel = new UserLocationModel();
         userLocationModel = userLocationService.FindLocationById(x.ClientId);
         if (x.JobAddress == null || x.JobAddress == "")
         {
             x.JobAddress = userLocationModel.Address;
         }
         //Get Employee Name 
         if (x.EmployeeId != null)
         {
             x.EmployeeModel = employeeServices.GetEmployeeById(x.EmployeeId);
         }
     });
     //Get serviceMapping
     List<JobServiceMappingModel> jobServiceMappingModel = new List<JobServiceMappingModel>();
     string[] jobIds = jobBindingModel.Select(u => u.JobId.ToString()).ToArray();
     jobServiceMappingModel = jobServiceMappingService.GetJobServiceMappingByJobIds(jobIds);
     List<JobServicePictureMappingModel> jobServicePictureMappingModel = new List<JobServicePictureMappingModel>();
     jobServicePictureMappingModel = jobServicePictruesMappingService.GetJobServicePictureMapping();
     jobBindingModel.ForEach(x =>
     {
         x.JobServiceMappings = jobServiceMappingModel.Where(j => j.JobId == x.JobId).ToList();
     });
     jobServiceMappingModel.ForEach(x =>
     {
         x.JobServicePictureMappings = jobServicePictureMappingModel.Where(j => j.JobServiceMappingId == x.JobServiceMappingId).ToList();
     });
     return jobBindingModel;
 }
コード例 #8
0
ファイル: JobsController.cs プロジェクト: codedive/MyDemo1
 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);
 }
コード例 #9
0
ファイル: JobsController.cs プロジェクト: codedive/MyDemo1
        public IHttpActionResult GetJobByServiceProviderId(string serviceProviderId)
        {
            //Get job
            List<JobBindingModel> jobBindingModel = new List<JobBindingModel>();
            List<JobModel> jobModel = new List<JobModel>();
            AutoMapper.Mapper.Map(jobBindingModel, jobModel);
            jobModel = jobService.GetJobListByServiceProviderId(serviceProviderId);
            AutoMapper.Mapper.Map(jobModel, jobBindingModel);

            jobBindingModel.ForEach(x =>
            {
                //Get Client Name
                ClientModel clientModel = new ClientModel();
                clientModel = clientService.GetClientById(x.ClientId);
                x.ClientName = clientModel.FirstName;
                //Get service City
                UserLocationModel userLocationModel = new UserLocationModel();
                userLocationModel = userLocationService.FindLocationById(x.ClientId);
                if (x.JobAddress == null || x.JobAddress=="")
                {
                    x.JobAddress = userLocationModel.Address;
                }
               
            });
            //Get serviceMapping
            List<JobServiceMappingModel> jobServiceMappingModel = new List<JobServiceMappingModel>();
            string[] jobIds = jobBindingModel.Select(u => u.JobId.ToString()).ToArray();
            jobServiceMappingModel = jobServiceMappingService.GetJobServiceMappingByJobIds(jobIds);
            List<JobServicePictureMappingModel> jobServicePictureMappingModel = new List<JobServicePictureMappingModel>();
            jobServicePictureMappingModel = jobServicePictruesMappingService.GetJobServicePictureMapping();
            jobBindingModel.ForEach(x =>
            {
                x.JobServiceMappings = jobServiceMappingModel.Where(j => j.JobId == x.JobId).ToList();
            });
            jobServiceMappingModel.ForEach(x =>
            {
                x.JobServicePictureMappings = jobServicePictureMappingModel.Where(j => j.JobServiceMappingId == x.JobServiceMappingId).ToList();
            });
            return Ok(jobBindingModel);
        }
コード例 #10
0
ファイル: ClientsController.cs プロジェクト: codedive/MyDemo1
        public IHttpActionResult MyTasks(string userId, string type)
        {
            List<JobBindingModel> jobBindingModel = new List<JobBindingModel>();
            try
            {
                //get job according to user id
                List<JobModel> jobModel = new List<JobModel>();
                JobStatus jobStatus = (JobStatus)Enum.Parse(typeof(JobStatus), type);
                jobModel = jobService.GetJobListByClientId(userId, jobStatus);
                AutoMapper.Mapper.Map(jobModel, jobBindingModel);
                //get job service mapping
                List<JobServiceMappingModel> jobServiceMappingModel = new List<JobServiceMappingModel>();
                string[] jobIds = jobBindingModel.Select(u => u.JobId.ToString()).ToArray();
                jobServiceMappingModel = jobServiceMappingService.GetJobServiceMappingByJobIds(jobIds);
                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.ForEach(x =>
                {
                    x.JobServiceMappings = jobServiceMappingModel.Where(j => j.JobId == x.JobId).ToList();
                });
                jobServiceMappingModel.ForEach(x =>
                {
                    x.JobServicePictureMappings = jobServicePictureMappingModel.Where(j => j.JobServiceMappingId == x.JobServiceMappingId).ToList();
                });
                //get employee inforamtion
                jobBindingModel.ForEach(x =>
                {
                    //Get employee Name
                    EmployeeModel EmployeeModel = new EmployeeModel();
                    EmployeeModel = employeeService.GetEmployeeById(x.EmployeeId);
                    x.EmployeeModel = EmployeeModel;
                    UserLocationModel userLocationModel = new UserLocationModel();
                    userLocationModel = userLocationService.FindLocationById(x.ClientId);
                    if (x.JobAddress == null)
                    {
                        x.JobAddress = userLocationModel.Address;
                        x.Latitude = userLocationModel.Latitude;
                        x.Longitude = userLocationModel.Latitude;
                    }
                    if (x.StartDate != null && x.EndDate != null)
                    {
                        TimeSpan difference = Convert.ToDateTime(x.EndDate).AddDays(3) - Convert.ToDateTime(x.StartDate);
                        var days = difference.TotalDays;
                        if(days <= 3)
                        {
                            x.IsExpired = false;
                        }
                        else
                        {
                            x.IsExpired = true;
                        }
                    }

                });

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
            return Ok(jobBindingModel);
        }
コード例 #11
0
ファイル: AccountController.cs プロジェクト: codedive/MyDemo1
        public async Task<IHttpActionResult> RegisterServiceProvider()
        {
            //using (var dataContext = new URFXDbContext())
            //{
            //    TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
            //    {
            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 plan = resultModel.FormData["planModel"];
                PlanServiceProviderModel planModel = new PlanServiceProviderModel();
                planModel = JsonConvert.DeserializeObject<PlanServiceProviderModel>(plan);
                var location = resultModel.FormData["LocationModel"];
                UserLocationModel locationModel = new UserLocationModel();
                locationModel = JsonConvert.DeserializeObject<UserLocationModel>(location);
                //var services = resultModel.FormData["services"];
                //string[] serviceIds = { string.Empty };
                //List<string> serviceIdList = new List<string>();
                //if (!string.IsNullOrEmpty(services))
                //{
                //    //serviceIds = services.Substring(1, services.Length - 1).Split(',');
                //    serviceIdList = new List<string>(services.Substring(1, services.Length - 2).Split(','));
                //    //serviceIdList.AddRange(serviceIds);
                //}
                var model = resultModel.FormData["model"];

                RegisterServiceProviderBindingModel serviceProviderModel = new RegisterServiceProviderBindingModel();
                serviceProviderModel = JsonConvert.DeserializeObject<RegisterServiceProviderBindingModel>(model);

                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }

                var user = new ApplicationUser() { UserName = serviceProviderModel.Email, Email = serviceProviderModel.Email, PhoneNumber = serviceProviderModel.PhoneNumber };

                IdentityResult result = await UserManager.CreateAsync(user, serviceProviderModel.Password);

                if (!result.Succeeded)
                {
                    // transaction.Dispose();
                    //UserManager.Delete(user);
                    return BadRequest("{\"status\" : false, \"message\" : \"Email id is already used\"}");
                }

                else
                {
                    serviceProviderModel.ServiceProviderId = user.Id;
                    serviceProviderModel.StartDate = DateTime.UtcNow;
                    IdentityResult resultRoleCreated = await UserManager.AddToRoleAsync(user.Id, URFXRoles.ServiceProvider.ToString());
                    if (!resultRoleCreated.Succeeded)
                    {
                        //  transaction.Dispose();
                        //UserManager.Delete(user);
                        return GetErrorResult(resultRoleCreated);
                    }
                    else
                    {
                        try
                        {
                            if (resultModel.FileData.Count > 0)
                            {
                                string fileName;

                                if (HttpContext.Current.Request.Files != null)
                                {
                                    for (var i = 0; i < resultModel.FileData.Count; i++)
                                    {
                                        var file = HttpContext.Current.Request.Files[i];
                                        fileName = file.FileName; 
                                        //// Load image.
                                        //Image image = Image.FromStream(file.InputStream);
                                        
                                        //// Compute thumbnail size.
                                        //Size thumbnailSize = GetThumbnailSize(image);
                                         

                                        if (i == 0)
                                        {
                                            file.SaveAs(Path.Combine(root, Utility.Constants.REGISTRATION_CERTIFICATE_PATH, fileName));
                                            serviceProviderModel.RegistrationCertificatePath = fileName;
                                            //var thumbnails= Guid.NewGuid() + ".jpg";
                                            // Get thumbnail.
                                            //Image thumbnail = image.GetThumbnailImage(thumbnailSize.Width,
                                            //    thumbnailSize.Height, null, IntPtr.Zero);
                                            //thumbnail.Save(Path.Combine(root, Utility.Constants.THUMBNAILSIMAGES, thumbnails));
                                        }
                                        else
                                        {
                                            file.SaveAs(Path.Combine(root, Utility.Constants.GOSI_CERTIFICATE_PATH, fileName));
                                            serviceProviderModel.GosiCertificatePath = fileName;
                                            //var thumbnails = Guid.NewGuid() + ".jpg";
                                            // Get thumbnail.
                                            //Image thumbnail = image.GetThumbnailImage(thumbnailSize.Width,
                                            //    thumbnailSize.Height, null, IntPtr.Zero);
                                            //thumbnail.Save(Path.Combine(root, Utility.Constants.THUMBNAILSIMAGES, thumbnails));
                                        }

                                    }

                                }

                            }
                            if (locationModel.CityId != 0)
                            {
                                locationModel.UserId = user.Id;
                                locationModel.DistrictId = 1;
                                userLocationService.InsertUserLocation(locationModel);
                            }
                            ServiceProviderModel serviceProviderModelEntity = new ServiceProviderModel();
                            AutoMapper.Mapper.Map(serviceProviderModel, serviceProviderModelEntity);
                            serviceProviderModelEntity = serviceProviderService.SaveServiceProvider(serviceProviderModelEntity);

                            AutoMapper.Mapper.Map(serviceProviderModelEntity, serviceProviderModel);
                            var Subject = Utility.Constants.CONFIRMATION_SUBJECT;
                            var code = UserManager.GenerateEmailConfirmationToken(user.Id);
                            var scheme = HttpContext.Current.Request.Url.Scheme;
                            var host = HttpContext.Current.Request.Url.Host;
                            var port = HttpContext.Current.Request.Url.Port > 0 ? ":" + HttpContext.Current.Request.Url.Port : "";
                            string language = "en";
                            var cookie = HttpContext.Current.Request.Cookies.Get("APPLICATION_LANGUAGE");
                            if (cookie != null)
                                language = cookie.Value;
                            string exactPath;
                            if (language == "en")
                            {
#if DEBUG
                                exactPath = scheme + "://" + host + port + "/Content/URFXTheme/images/logo.png";
#else
                                exactPath = scheme + "://" + host + "/Content/URFXTheme/images/logo.png";
#endif
                            }
                            else
                            {
#if DEBUG
                                exactPath = scheme + "://" + host + port + "/Content/URFXTheme/images/arabic-logo.png";
#else
                                exactPath = scheme + "://" + host + "/Content/URFXTheme/images/arabic-logo.png";
#endif
                            }
                            //var exactPath = scheme + "://" + host + "/Content/URFXTheme/images/logo.png";
#if DEBUG
                            var link = scheme + "://" + host + port + "/App/#/confirmemail/" + user.Id + "";
#else
                             var link = scheme + "://" + host + "/App/#/confirmemail/" + user.Id + "";
#endif
                            var Link = "<a href='" + link + "'>" + link + "</a>";

                            string text = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath(Utility.Constants.CONFIRMATION_EMAIL_PATH));
                            String Body = "";
                            Body = String.Format(text, user.UserName, Link, exactPath);
                            try
                            {
                                // await service.SendAsync(message);
                                await UserManager.SendEmailAsync(user.Id, Subject, Body);
                            }
                            catch (Exception ex)
                            {

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

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

                }

                return Ok();
            }
            catch (Exception ex)
            {
                //  transaction.Dispose();
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
            //    }
            //}
        }
コード例 #12
0
ファイル: AccountController.cs プロジェクト: codedive/MyDemo1
        public async Task<IHttpActionResult> RegisterClient(RegisterClientBindingModel model)
        {
            //using (var dataContext = new URFXDbContext())
            //{
            //    TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
            //    {
            try
            {
                if (model.RegistrationType == RegistrationType.Simple)
                {
                    var user = new ApplicationUser()
                    {
                        UserName = model.Email,
                        Email = model.Email,
                        PhoneNumber = model.PhoneNumber,
                        DeviceType = model.DeviceType,
                        DeviceToken = model.DeviceToken,
                        RegistrationType = model.RegistrationType,
                        FacebookId = model.FacebookId,
                        GoogleId = model.GoogleId,
                        TwitterId = model.TwitterId
                    };
                    IdentityResult result = await UserManager.CreateAsync(user, model.Password);
                    if (!result.Succeeded)
                    {
                        // transaction.Dispose();
                        return GetErrorResult(result);
                    }

                    else
                    {
                        model.ClientId = user.Id;
                        IdentityResult resultRoleCreated = await UserManager.AddToRoleAsync(user.Id, URFXRoles.Client.ToString());
                        if (!resultRoleCreated.Succeeded)
                        {
                            // transaction.Dispose();
                            return GetErrorResult(resultRoleCreated);
                        }
                        else
                        {
                           try
                            {
                                //generate OTP 
                                Random r = new Random();
                                int randNum = r.Next(1000000);
                                string sixDigitNumber = randNum.ToString("D6");
                                model.OTP = sixDigitNumber;
                                //Save Client
                                ClientModel clientModel = new ClientModel();
                                AutoMapper.Mapper.Map(model, clientModel);
                                clientModel = clientService.SaveClient(clientModel);
                                AutoMapper.Mapper.Map(clientModel, model);
                                //save location for client
                                UserLocationModel locationModel = new UserLocationModel();
                                locationModel.UserId = user.Id;
                                locationModel.CityId = model.CityId;
                                locationModel.DistrictId = 1;
                                locationModel.Latitude = model.Latitude;
                                locationModel.Longitude = model.Longitude;
                                locationModel.Address = model.Address;
                                if (locationModel.Address != null)
                                {
                                    locationModel = userLocationService.InsertUserLocation(locationModel);
                                }

                                //Send Email
                                var code = UserManager.GenerateEmailConfirmationToken(user.Id);
                                var scheme = HttpContext.Current.Request.Url.Scheme;
                                var host = HttpContext.Current.Request.Url.Host;
                                var port = HttpContext.Current.Request.Url.Port > 0 ? ":" + HttpContext.Current.Request.Url.Port : "";
                                string language = "en";
                                var cookie = HttpContext.Current.Request.Cookies.Get("APPLICATION_LANGUAGE");
                                if (cookie != null)
                                    language = cookie.Value;
                                string exactPath;
                                if (language == "en")
                                {
#if DEBUG
                                    exactPath = scheme + "://" + host + port + "/Content/URFXTheme/images/logo.png";
#else
                                    exactPath = scheme + "://" + host + "/Content/URFXTheme/images/logo.png";
#endif
                                }
                                else
                                {
#if DEBUG
                                    exactPath = scheme + "://" + host + port + "/Content/URFXTheme/images/arabic-logo.png";
#else
                                    exactPath = scheme + "://" + host + "/Content/URFXTheme/images/arabic-logo.png";
#endif

                                }
                                // var exactPath = scheme + "://" + host + port + "/Content/URFXTheme/images/logo.png";
                                //var exactPath = scheme + "://" + host + "/Content/URFXTheme/images/logo.png";
                                var Subject = Utility.Constants.CONFIRMATION_SUBJECT;
                                string text = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath(Utility.Constants.CONFIRMATION_OTP_PATH));
                                String Body = "";
                                Body = String.Format(text, user.UserName, sixDigitNumber, exactPath);
                                try
                                {
                                    await UserManager.SendEmailAsync(user.Id, Subject, Body);
                                }
                                catch (Exception ex)
                                {
                                    // transaction.Dispose();
                                    Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                                    return BadRequest(ex.Message);
                                }
                                //transaction.Complete();
                            }
                            catch (Exception ex)
                            {
                                // transaction.Dispose();
                                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                                return BadRequest(ex.Message);
                            }
                        }
                    }
                }
                else
                {
                    if (model.Password == null && model.RegistrationType == RegistrationType.Facebook)
                    {
                        model.Password = model.FacebookId;
                    }
                    else if (model.Password == null && model.RegistrationType == RegistrationType.Google)
                    {
                        model.Password = model.GoogleId;
                    }
                    else if (model.Password == null && model.RegistrationType == RegistrationType.Twitter)
                    {
                        model.Password = model.TwitterId;
                    }
                    var checkUser = UserManager.FindByEmail(model.Email);
                    if (checkUser == null)
                    {
                        var user = new ApplicationUser()
                        {
                            UserName = model.Email,
                            Email = model.Email,
                            PhoneNumber = model.PhoneNumber,
                            DeviceType = model.DeviceType,
                            DeviceToken = model.DeviceToken,
                            RegistrationType = model.RegistrationType,
                            FacebookId = model.FacebookId,
                            GoogleId = model.GoogleId,
                            TwitterId = model.TwitterId,
                            IsRegister = true,
                            IsLogin = false

                        };
                        IdentityResult result = await UserManager.CreateAsync(user, model.Password);
                        if (!result.Succeeded)
                        {
                            //  transaction.Dispose();
                            return GetErrorResult(result);
                        }

                        else
                        {
                            model.ClientId = user.Id;
                            IdentityResult resultRoleCreated = await UserManager.AddToRoleAsync(user.Id, URFXRoles.Client.ToString());
                            //Save Client
                            try
                            {
                                ClientModel clientModel = new ClientModel();
                                AutoMapper.Mapper.Map(model, clientModel);
                                clientModel = clientService.SaveClient(clientModel);
                                AutoMapper.Mapper.Map(clientModel, model);

                                //save location for client
                                UserLocationModel locationModel = new UserLocationModel();
                                locationModel.UserId = user.Id;
                                locationModel.CityId = model.CityId;
                                locationModel.DistrictId = 1;
                                locationModel.Latitude = model.Latitude;
                                locationModel.Longitude = model.Longitude;
                                locationModel.Address = model.Address;
                                if (locationModel.Address != null)
                                {
                                    locationModel = userLocationService.InsertUserLocation(locationModel);
                                }
                                //check if register using facebook,google,twitter
                                string token = GetToken(user.UserName, model.Password);
                                var json = JsonConvert.DeserializeObject(token);
                                //    transaction.Complete();
                                return Json(json);

                            }
                            catch (Exception ex)
                            {
                                //  transaction.Dispose();
                                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                                return BadRequest(ex.Message);
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            if (checkUser.RegistrationType == model.RegistrationType)
                            {

                                checkUser.DeviceType = model.DeviceType;
                                checkUser.DeviceToken = model.DeviceToken;
                                checkUser.IsLogin = true;
                                //UserManager.Update(checkUser);
                                IdentityResult result = await UserManager.UpdateAsync(checkUser);
                                //update client
                                ClientModel clientModel = new ClientModel();
                                clientModel = clientService.GetClientById(checkUser.Id);
                                //if (clientModel.ClientId != null)
                                //{
                                //    clientModel.QuickBloxId = model.QuickBloxId;
                                //    clientModel = clientService.UpadteClient(clientModel);
                                //}

                                //update location for client
                                UserLocationModel locationModel = new UserLocationModel();
                                locationModel = userLocationService.FindLocationById(checkUser.Id);
                                locationModel.UserId = checkUser.Id;
                                locationModel.CityId = model.CityId;
                                locationModel.DistrictId = 1;
                                locationModel.Latitude = model.Latitude;
                                locationModel.Longitude = model.Longitude;
                                locationModel.Address = model.Address;
                                if (locationModel.UserLocationId > 0)
                                {
                                    locationModel = userLocationService.UpadteUserLocation(locationModel);
                                }
                                else
                                {
                                    locationModel = userLocationService.InsertUserLocation(locationModel);
                                }
                                var resetToken = await UserManager.GeneratePasswordResetTokenAsync(checkUser.Id);
                                await UserManager.ResetPasswordAsync(checkUser.Id, resetToken, model.Password);
                                string token = GetToken(checkUser.UserName, model.Password);
                                var json = JsonConvert.DeserializeObject(token);
                                //   transaction.Complete();
                                return Json(json);
                            }

                            else
                            {
                                if (model.RegistrationType == RegistrationType.Google)
                                {
                                    checkUser.RegistrationType = model.RegistrationType;
                                    checkUser.GoogleId = model.GoogleId;
                                    checkUser.DeviceType = model.DeviceType;
                                    checkUser.DeviceToken = model.DeviceToken;
                                    checkUser.IsLogin = true;
                                    //UserManager.Update(checkUser);
                                    IdentityResult result = await UserManager.UpdateAsync(checkUser);
                                    //update client
                                    ClientModel clientModel = new ClientModel();
                                    clientModel = clientService.GetClientById(checkUser.Id);
                                    //if (clientModel.ClientId != null)
                                    //{
                                    //    clientModel.QuickBloxId = model.QuickBloxId;
                                    //    clientModel = clientService.UpadteClient(clientModel);
                                    //}
                                    
                                    //update location for client
                                    UserLocationModel locationModel = new UserLocationModel();
                                    locationModel = userLocationService.FindLocationById(checkUser.Id);
                                    locationModel.UserId = checkUser.Id;
                                    locationModel.CityId = model.CityId;
                                    locationModel.DistrictId = 1;
                                    locationModel.Latitude = model.Latitude;
                                    locationModel.Longitude = model.Longitude;
                                    locationModel.Address = model.Address;
                                    if (locationModel.UserLocationId > 0)
                                    {
                                        locationModel = userLocationService.UpadteUserLocation(locationModel);
                                    }
                                    else
                                    {
                                        locationModel = userLocationService.InsertUserLocation(locationModel);
                                    }
                                    var resetToken = await UserManager.GeneratePasswordResetTokenAsync(checkUser.Id);
                                    await UserManager.ResetPasswordAsync(checkUser.Id, resetToken, model.Password);
                                    string token = GetToken(checkUser.UserName, model.Password);
                                    var json = JsonConvert.DeserializeObject(token);
                                    //   transaction.Complete();
                                    return Json(json);
                                }
                                else
                                {
                                    checkUser.RegistrationType = model.RegistrationType;
                                    checkUser.TwitterId = model.TwitterId;
                                    checkUser.DeviceType = model.DeviceType;
                                    checkUser.DeviceToken = model.DeviceToken;
                                    checkUser.IsLogin = true;
                                    //UserManager.Update(checkUser);
                                    IdentityResult result = await UserManager.UpdateAsync(checkUser);
                                    //update client
                                    ClientModel clientModel = new ClientModel();
                                    clientModel = clientService.GetClientById(checkUser.Id);
                                    //if (clientModel.ClientId != null)
                                    //{
                                    //    clientModel.QuickBloxId = model.QuickBloxId;
                                    //    clientModel = clientService.UpadteClient(clientModel);
                                    //}
                                    
                                    //update location for client
                                    UserLocationModel locationModel = new UserLocationModel();
                                    locationModel = userLocationService.FindLocationById(checkUser.Id);
                                    locationModel.UserId = checkUser.Id;
                                    locationModel.CityId = model.CityId;
                                    locationModel.DistrictId = 1;
                                    locationModel.Latitude = model.Latitude;
                                    locationModel.Longitude = model.Longitude;
                                    locationModel.Address = model.Address;
                                    if (locationModel.UserLocationId > 0)
                                    {
                                        locationModel = userLocationService.UpadteUserLocation(locationModel);
                                    }
                                    else
                                    {
                                        locationModel = userLocationService.InsertUserLocation(locationModel);
                                    }
                                    var resetToken = await UserManager.GeneratePasswordResetTokenAsync(checkUser.Id);
                                    await UserManager.ResetPasswordAsync(checkUser.Id, resetToken, model.Password);
                                    string token = GetToken(checkUser.UserName, model.Password);
                                    var json = JsonConvert.DeserializeObject(token);
                                    //   transaction.Complete();
                                    return Json(json);
                                }
                            }


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


            }
            catch (Exception ex)
            {
                // transaction.Dispose();
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
            //    }
            //}
            return Ok(model);
        }
コード例 #13
0
 public UserLocationModel UpadteUserLocation(UserLocationModel model)
 {
     //unitOfWork.StartTransaction();
     UserLocationRepository repo = new UserLocationRepository(unitOfWork);
     UserLocation userLocation = new UserLocation();
     userLocation = repo.GetAll().Where(x => x.UserLocationId == model.UserLocationId).FirstOrDefault();
     AutoMapper.Mapper.Map(model, userLocation);
     repo.Update(userLocation);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(userLocation, model);
     return model;
 }
コード例 #14
0
 public UserLocationModel InsertUserLocation(UserLocationModel locationModel)
 {
     //unitOfWork.StartTransaction();
     UserLocationRepository repo = new UserLocationRepository(unitOfWork);
     //UserLocationModel userLocationModel = new UserLocationModel();
     UserLocation userLocation = new UserLocation();
     AutoMapper.Mapper.Map(locationModel, userLocation);
     userLocation = repo.Insert(userLocation);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(userLocation, locationModel);
     return locationModel;
 }