public async Task <JobPart> CreateJobPartAsync(int jobId, JobPart jobPart, int UserId)
        {
            jobPart.JobId = jobId;
            Repo.AddOrUpdate(jobPart);
            await Repo.SaveAsUserAsync(UserId);

            var jobPartGraph = Repo.GetGraphs(x => x.Id == jobPart.Id).SingleOrDefault();

            NettingManager.EnsureDaughterJob(jobPartGraph);
            await Repo.SaveAsUserAsync(UserId);

            return(jobPartGraph);
        }
        public async Task<IHttpActionResult> PostEmail(int id, [FromBody] EmailBindingModel email)
        {
            var newEmail = Mapper.Map<Email>(email);
            newEmail.ContactPersonId = id;
            Repository.AddOrUpdate(newEmail);
            await Repository.SaveAsUserAsync(UserId);

            var newlyAdded = await Repository.Get(x => x.Id == newEmail.Id).FirstOrDefaultAsync();
            if (newlyAdded != null)
            {
                var model = Mapper.Map<EmailViewModel>(newlyAdded);
                return Ok(model);
            }
            else
                return InternalServerError();
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> PostOtherContact(int id, [FromBody] ProviderProfileOtherContactBindingModel contact)
        {
            var newContact = Mapper.Map <OtherContact>(contact);

            newContact.PersonId = id;
            Repository.AddOrUpdate(newContact);
            await Repository.SaveAsUserAsync(UserId);

            var newlyAdded = await Repository.Get(x => x.Id == newContact.Id).FirstOrDefaultAsync();

            if (newlyAdded != null)
            {
                var model = Mapper.Map <OtherContactViewModel>(newlyAdded);
                return(Ok(model));
            }
            else
            {
                return(InternalServerError());
            }
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> PostPhone(int id, [FromBody] PhoneBindingModel phone)
        {
            var newPhone = Mapper.Map <Phone>(phone);

            newPhone.ContactPersonId = id;
            Repository.AddOrUpdate(newPhone);
            await Repository.SaveAsUserAsync(UserId);

            var newlyAdded = await Repository.Get(x => x.Id == newPhone.Id).FirstOrDefaultAsync();

            if (newlyAdded != null)
            {
                var model = Mapper.Map <PhoneViewModel>(newlyAdded);
                return(Ok(model));
            }
            else
            {
                return(InternalServerError());
            }
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> Post([FromBody] IndividualProviderModel model)
        {
            if (ModelState.IsValid)
            {
                var provider = Mapper.Map <Provider>(model);
                _providerRepo.AddOrUpdate(provider);

                var result = await _providerRepo.TrySaveAsUserAsync(UserId);

                if (result.Success)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest(result.ErrorMessage));
                }
            }
            else
            {
                return(BadRequest(ModelValidationErrorMessage));
            }
        }