Esempio n. 1
0
        public static AttendeeModel Create(Attendee obj)
        {
            if (obj == null)
                return null;

            var model = new AttendeeModel()
            {
                Id = obj.Id,
                Code  = obj.Code,
                EmailAddress = obj.EmailAddress,
                JobTitle = obj.JobTitle,
                Name =obj.Name
            };

            var proposals = new List<TalkProposalModel>();
            if (obj.TalkProposals != null)
            {
                foreach (var talkProposalReference in obj.TalkProposals)
                {
                    proposals.Add(Create(talkProposalReference));
                }
            }
            model.TalkProposals = proposals;

            return model;
        }
Esempio n. 2
0
        internal static Entities.Attendee Parse(AttendeeModel model, Attendee obj)
        {
            if (model == null)
            {
                return null;
            }

            if (obj != null)
            {
                obj.Name = model.Name;
                obj.JobTitle = model.JobTitle;
                obj.Code = model.Code;
                obj.EmailAddress = model.EmailAddress;

            }

            return obj;
        }
        public async Task<IHttpActionResult> PostAttendees(AttendeeModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var attendee = new Attendee();
            attendee = ObjectFactory.Parse(model, attendee);
            attendee.ObjectState = ObjectState.Added;
            _attendeeService.Insert(attendee);
            await _unitOfWork.SaveChangesAsync();

            model = ModelFactory.Create(attendee);
            return CreatedAtRoute("DefaultApi", new { id = model.Id }, model);
        }