Beispiel #1
0
        public static void FillOfferings(ComboBox cmb)
        {
            OfferingViewModel offeringViewModel = new OfferingViewModel();

            cmb.DisplayMember = "OfferingName";
            cmb.ValueMember   = "OfferingId";
            cmb.DataSource    = offeringViewModel.GetAllOfferings().ToList();
        }
Beispiel #2
0
        public ActionResult <OfferingViewModel> Update(int id, OfferingViewModel offering)
        {
            if (ModelState.IsValid && offering.Id == id)
            {
                var updatedOffering = this._offeringRepository.GetItemById(offering.Id);
                _mapper.Map(offering, updatedOffering);
                this._offeringRepository.Update(updatedOffering);

                return(Ok(offering));
            }

            return(BadRequest(offering));
        }
        public async Task <ActionResult <OfferingViewModel> > CreateAsync(OfferingViewModel offeringView)
        {
            if (ModelState.IsValid)
            {
                var offering = _mapper.Map <OfferingViewModel, Offering>(offeringView);

                var createdOffering = await _service.CreateAsync(offering);

                offeringView.Id = createdOffering.Id;

                return(CreatedAtAction(nameof(GetByIdAsync), new { id = offeringView.Id }, offeringView));
            }

            return(BadRequest(offeringView));
        }
Beispiel #4
0
 private void txt_OfferingCode_Leave(object sender, EventArgs e)
 {
     if (Common.ValidateIntOnly((TextBox)sender))
     {
         int code = Convert.ToInt32(txt_OfferingCode.Text);
         OfferingViewModel viewModel = new OfferingViewModel();
         var offering = viewModel.GetByCode(code);
         if (offering != null)
         {
             cmb_Offering.SelectedValue = offering.OfferingId;
         }
         else
         {
             MessageBox.Show("കോഡ് തെറ്റാണ് ");
             txt_OfferingCode.Text = string.Empty;
             txt_OfferingCode.Focus();
         }
     }
 }
Beispiel #5
0
        public ActionResult <OfferingViewModel> Create(OfferingViewModel offering, int familyId)
        {
            if (ModelState.IsValid)
            {
                var family = _familyRepository.GetItemById(familyId, null);
                if (family != null)
                {
                    var newOffering = _mapper.Map <OfferingViewModel, Offering>(offering);
                    newOffering.FamilyId = familyId;
                    this._offeringRepository.Create(newOffering);

                    var createdOffering = _mapper.Map <Offering, OfferingViewModel>(newOffering);
                    return(CreatedAtAction(nameof(GetById), new { id = newOffering.Id }, createdOffering));
                }

                return(NotFound(new { Message = "Family not found!" }));
            }

            return(BadRequest(ModelState));
        }
        public async Task <ActionResult> UpdateAsync(OfferingViewModel offeringView, int id)
        {
            if (id == offeringView.Id)
            {
                if (ModelState.IsValid)
                {
                    var family = _mapper.Map <OfferingViewModel, Offering>(offeringView);
                    await _service.UpdateAsync(id, family);

                    return(NoContent());
                }

                return(BadRequest(offeringView));
            }

            return(BadRequest(
                       new
            {
                title = "The Id of passed entity is not equal to id passed through a query string"
            }));
        }
Beispiel #7
0
 public Offering()
 {
     InitializeComponent();
     lblMsg.Text       = null;
     offeringViewModel = new OfferingViewModel();
 }
        public static OfferingViewModel ToViewModel(this Offering model)
        {
            OfferingViewModel result = new OfferingViewModel();

            result.OfferingGuid = model.OfferingGuid;
            result.OfferingID = model.OfferingID;
            result.OfferingName = model.OfferingName;

            return result;
        }