예제 #1
0
 public SubServiceModel GetAllCategoryServiceByServiceId(int ServiceId)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     SubServiceModel subServiceList = new SubServiceModel();
     Service service = new Service();
     AutoMapper.Mapper.Map(subServiceList, service);
     service = repo.GetAll().Where(x => x.ServiceId == ServiceId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, subServiceList);
     return subServiceList;
 }
예제 #2
0
 public SubServiceModel SaveSubService(SubServiceModel model)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     Service service = new Service();
     AutoMapper.Mapper.Map(model, service);
     repo.Insert(service);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, model);
     return model;
 }
예제 #3
0
 public SubServiceModel UpadteSubService(SubServiceModel model)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     Service service = new Service();
     service = repo.GetAll().Where(x => x.ServiceId == model.ServiceId).FirstOrDefault();
     AutoMapper.Mapper.Map(model, service);
     repo.Update(service);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, model);
     return model;
 }
예제 #4
0
        public async Task<IHttpActionResult> SaveService()
        {
            try
            {
                if (!Request.Content.IsMimeMultipartContent())
                {
                    return BadRequest();
                }
                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)
                {
                    return BadRequest();
                }

                var model = resultModel.FormData["model"];
                Service serviceModal = new Service();
                serviceModal = JsonConvert.DeserializeObject<Service>(model);

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

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

        }