Exemplo n.º 1
0
        public JsonResult AddPersonRiskFactor(PersonRiskFactor personRiskFactor)
        {
            var isSuccessfully = true;
            var error = string.Empty;

            try
            {
                this.personRiskFactorRepository.CreateOrUpdateEntity(personRiskFactor);
            }
            catch (Exception ex)
            {
                isSuccessfully = false;
                error = ex.Message;
            }

            return this.Json(new { IsSuccessfully = isSuccessfully, Error = error });
        }
Exemplo n.º 2
0
        public PersonRiskFactor CreateOrUpdateEntity(PersonRiskFactor entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            using (var context = new TrashDomainContext(this.ConnectionString))
            {
                if (this.GetEntityById(entity.Id) == null)
                {
                    context.PersonRiskFactors.Add(entity);
                }
                else
                {
                    context.Entry(entity).State = EntityState.Modified;
                }

                context.SaveChanges();
            }

            return entity;
        }