예제 #1
0
        public UsocToCommandTranslation CreateOrUpdateUsocTranslation(UsocToCommandTranslation usocToCommandTranslation, string updatingUserId)
        {
            var data = _andpEquipmentEntities.UsocToCommandTranslations.AsNoTracking().FirstOrDefault(p => p.Id == usocToCommandTranslation.Id);

            usocToCommandTranslation.ModifiedByUser = updatingUserId;
            usocToCommandTranslation.DateModified   = DateTime.Now;
            usocToCommandTranslation.Version        = 0;

            if (data != null && data.Id > 0)
            {
                usocToCommandTranslation.Id            = data.Id;
                usocToCommandTranslation.Version       = data.Version;
                usocToCommandTranslation.CreatedByUser = data.CreatedByUser;
                usocToCommandTranslation.DateCreated   = data.DateCreated;
            }
            else
            {
                usocToCommandTranslation.CreatedByUser = updatingUserId;
                usocToCommandTranslation.DateCreated   = DateTime.Now;
            }

            _andpEquipmentEntities.AttachEntity(null, usocToCommandTranslation, new[] { "Id" }, updatingUserId);
            _andpEquipmentEntities.SaveChanges();
            _andpEquipmentEntities.RefreshEntity(usocToCommandTranslation);
            return(usocToCommandTranslation);
        }
예제 #2
0
        public HttpResponseMessage CreateOrUpdateUsocTranslation([FromBody] UsocToCommandTranslation usocToCommandTranslation)
        {
            try
            {
                Setup();

                _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in " + _name), LogLevelType.Info);
                var data = _equipmentService.CreateOrUpdateUsocTranslation(usocToCommandTranslation, _user);
                return(this.Request.CreateResponse(HttpStatusCode.Created, data));
            }
            catch (Exception ex)
            {
                _logger.WriteLogEntry(_tenantId.ToString(), new List <object> {
                    ex.RetrieveEntityExceptionDataAsObjectList()
                },
                                      string.Format(MethodBase.GetCurrentMethod().Name + " in " + _name), LogLevelType.Error, ex.GetInnerMostException());
                throw ex.AddEntityValidationInfo();
            }
        }