/// <summary> /// Saves the offering to DB. /// </summary> private void SaveOffering() { var selectedItem = (DeityDto)cmbDeity.SelectedItem; if (selectedItem != null) { OfferingDto offeringDto = new OfferingDto { OfferingName = txtOfferingName.Text, Price = Convert.ToDecimal(txtPrice.Text), MaxPerDay = Convert.ToInt16(txtMaxPerDay.Text), IsBookable = chk_IsBooked.Checked, DeityID = selectedItem.DeityId, Code = Convert.ToInt16(txtCode.Text) }; if (offeringViewModel.InsertOffering(offeringDto)) { ClearControls(); lblMsg.Text = "വഴിപാട് ചേർത്തിരിക്കുന്നു "; } } else { lblMsg.Text = "ദയവായി ഒരു പ്രതിഷ്ട തിരഞ്ഞെടുക്കുകുക "; } }
public IHttpActionResult Post(OfferingDto form) { if (ModelState.IsValid) { try { var offering = Mapper.Map <OfferingDto, Offering>(form); _offeringService.Add(offering); var offeringDto = GetOfferingDto(offering); return(Created(new Uri(offeringDto.Url), offeringDto)); } catch (ArgumentException ae) { ModelState.AddModelError("", ae.Message); } catch (PreexistingEntityException pe) { ModelState.AddModelError("", pe.Message); } } return(BadRequest(ModelState)); }
/// <summary> /// Get all offerings from the db. /// </summary> /// <returns></returns> public IEnumerable <OfferingDto> GetAllOfferings() { OfferingDto dto = new OfferingDto(); var entities = repository.GetAll(); return(dto.ToObjects(entities)); }
private ProjectDto Map(Project project) { if (project == null) { return(null); } var projectDto = new ProjectDto(); projectDto.Id = project.Id; projectDto.Name = project.Name; projectDto.DXCServices = project.DXCServices; projectDto.Facts = project.Facts; projectDto.DXCSolution = project.DXCSolution; projectDto.Betriebsleistung = project.Betriebsleistung; if (project.Customer != null) { var dc = new CustomerDto(); dc.Id = project.Customer.Id; dc.Name = project.Customer.Name; projectDto.Customer = dc; } if (project.Industry != null) { var di = new IndustryDto(); di.Id = project.Industry.Id; di.Name = project.Industry.Name; projectDto.Industry = di; } foreach (Region r in project.Regions) { var dr = new RegionDto(); dr.Id = r.Id; dr.Name = r.Name; dr.KeyNamePath = r.KeyNamePath; projectDto.Regions.Add(dr); } foreach (Offering o in project.Offerings) { var doff = new OfferingDto(); doff.Id = o.Id; doff.Name = o.Name; doff.KeyNamePath = o.KeyNamePath; projectDto.Offerings.Add(doff); } foreach (Skill s in project.Skills) { var ds = new SkillDto(); ds.Id = s.Id; ds.Name = s.Name; projectDto.Skills.Add(ds); } return(projectDto); }
public OfferingFormViewModel(OfferingDto offering) { Id = offering.Id; Title = offering.Title; Location = offering.Location; OfferingDays = offering.OfferingDays; Notes = offering.Notes; ProfessorId = offering.ProfessorId; CourseId = offering.CourseId; TermId = offering.TermId; }
/// <summary> /// Gets the Offering object based on the code supplied. /// </summary> /// <param name="code"></param> /// <returns></returns> public OfferingDto GetByCode(int code) { OfferingDto dto = new OfferingDto(); var entity = repository.Collect(p => p.Code == code).FirstOrDefault(); if (entity != null) { return(dto.ToObject(entity)); } return(null); }
public bool InsertOffering(OfferingDto offeringDto) { try { repository.Insert(offeringDto.ToEntity(offeringDto)); return(true); } catch (Exception ex) { return(false); } }
public async Task <IActionResult> Get(int id) { OfferingDto offering = await offeringService.GetOfferingAsync(id); if (offering == null) { return(NotFound()); } var offeringViewModel = mapper.Map <OfferingDto, OfferingViewModel>(offering); return(Ok(offeringViewModel)); }
public async Task <ActionResult> Save(OfferingFormViewModel form) { if (ModelState.IsValid) { try { OfferingDto offering = (form.IsNew) ? new OfferingDto() : await _offeringRepository.GetOfferingById(form.Id.Value); offering.Title = form.Title; offering.Location = form.Location; offering.OfferingDays = form.OfferingDays; offering.Notes = form.Notes; offering.ProfessorId = form.ProfessorId; offering.CourseId = form.CourseId; offering.TermId = form.TermId; if (form.IsNew) { await _offeringRepository.PostOffering(offering); } else { await _offeringRepository.PutOffering(offering.Id, offering); } AddPageAlerts(ViewHelpers.PageAlertType.Success, "Your changes have been saved succesfully."); return(RedirectToAction("View", new { termId = form.TermId })); } catch (BadRequestException bre) { AddErrorsFromAdycHttpExceptionToModelState(bre, ModelState); } } await SetOfferingListProperties(form); // Add properties to layout AddPageHeader(form.FormTitle, ""); AddBreadcrumb("Offerings (Terms)", Url.Action("Index")); AddBreadcrumb("Offerings (List)", Url.Action("View", new { TermId = form.TermId })); AddBreadcrumb(form.FormTitle, ""); return(View("OfferingForm", form)); }
public async Task <IEnumerable <OfferingDto> > GetProjectChildOfferingsByKeyNamePathsAsync(string keyNamePath) { var rr = await this.projectRepository.GetProjectChildOfferingsByKeyNamePath(keyNamePath); IList <OfferingDto> offeringDtos = new List <OfferingDto>(); foreach (Offering o in rr) { var d = new OfferingDto(); d.Id = o.Id; d.Name = o.Name; d.KeyNamePath = o.KeyNamePath; offeringDtos.Add(d); } return(offeringDtos); }
public async Task <IList <OfferingDto> > ListAllLocationsAsync() { var pp = await this._OfferingRepository.GetAllAsync(); IList <OfferingDto> offeringDtos = new List <OfferingDto>(); foreach (Offering r in pp) { var d = new OfferingDto(); d.Id = r.Id; d.Name = r.Name; d.KeyNamePath = r.KeyNamePath; offeringDtos.Add(d); } return(offeringDtos); }
public IHttpActionResult Put(int id, [FromBody] OfferingDto form) { if (ModelState.IsValid) { var offeringInDb = _offeringService.Get(id); if (offeringInDb == null) { return(NotFound()); } Mapper.Map(form, offeringInDb); _offeringService.Update(offeringInDb); return(Ok()); } return(BadRequest(ModelState)); }