Example #1
0
        private void SetProfessionalReference(Konsultant newConsultant, ProfessionalReferenceViewModel refer)
        {
            ProfessionalReference current;

            if (string.IsNullOrEmpty(refer.Id))
            {
                current = new ProfessionalReference
                {
                    Name         = refer.Name,
                    Surname      = refer.Surname,
                    Function     = refer.Function,
                    KonsultantId = newConsultant.Id,
                    Company      = refer.Company
                };

                var Contacts = new Contact
                {
                    Mail  = refer.Mail,
                    Phone = refer.Phone,
                    ProfessionalReferenceId = current.Id,
                };

                current.Contacts = Contacts;
                newConsultant.ProfessionalReferences.Add(current);
            }
        }
        public async Task <IActionResult> PutProfessionalReference(int id, ProfessionalReference professionalReference)
        {
            if (id != professionalReference.Id)
            {
                return(BadRequest());
            }

            _context.Entry(professionalReference).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProfessionalReferenceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
        public ActionResult _RefInsertAjaxEditing(int appId)
        {
            var inserted = new ProfessionalReference { Application = { ApplicationID = appId } };

            TryUpdateModel(inserted);

            _repository.Save<ProfessionalReference>(inserted);

            return View("Create", new GridModel(_repository.All<ProfessionalReference>().Where(r => r.Application.ApplicationID == appId)));
        }
        private static void CreateOrUpdateProfessionalReference(KlanikContext _context, ProfessionalReference refer)
        {
            var referExists = _context.ProfessionalReferences.Any(x => x.Id == refer.Id);

            _context.Entry(refer).State =
                referExists ?
                EntityState.Modified :
                EntityState.Added;

            if (!referExists)
            {
                var contact = new Contact
                {
                    Mail  = refer.Contacts.Mail,
                    Phone = refer.Contacts.Phone,
                    ProfessionalReference = refer
                };

                _context.Entry(contact).State = EntityState.Added;
            }
        }
        public async Task <ActionResult <ProfessionalReference> > PostProfessionalReference(ProfessionalReference professionalReference)
        {
            _context.ProfessionalReferences.Add(professionalReference);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProfessionalReference", new { id = professionalReference.Id }, professionalReference));
        }