Ejemplo n.º 1
0
 public BaseResponse <bool> Update(YachtOtherInformationAddOrUpdateModel model)
 {
     try
     {
         var entity = _context.YachtOtherInformations.Find(model.Id);
         if (entity != null)
         {
             entity.Title            = model.Title;
             entity.Descriptions     = model.Descriptions;
             entity.InfoTypeFid      = model.InfoTypeFid;
             entity.LanguageFid      = model.LanguageFid;
             entity.FileStreamFid    = model.FileStreamFid > 0 ? model.FileStreamFid : entity.FileStreamFid;
             entity.FileTypeFid      = model.FileTypeFid > 0 ? model.FileTypeFid : entity.FileTypeFid;
             entity.LastModifiedBy   = GetUserGuidId();
             entity.LastModifiedDate = DateTime.Now;
             _context.SaveChanges();
             return(BaseResponse <bool> .Success(true));
         }
         return(BaseResponse <bool> .NotFound(false));
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
        public IActionResult Create([FromBody] YachtOtherInformationAddOrUpdateModel model)
        {
            var result = _yachtOtherInformationService.Create(model);

            if (result.IsSuccessStatusCode)
            {
                return(Ok(model));
            }

            return(BadRequest());
        }
 public IActionResult Update(YachtOtherInformationAddOrUpdateModel model)
 {
     if (model != null)
     {
         var result = _yachtOtherInformationService.Update(model);
         if (result.IsSuccessStatusCode)
         {
             return(Ok(result));
         }
     }
     return(BadRequest());
 }
Ejemplo n.º 4
0
        public BaseResponse <bool> Create(YachtOtherInformationAddOrUpdateModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BaseResponse <bool> .BadRequest());
                }

                DateTime?activatedDate = null;
                if (!string.IsNullOrEmpty(model.ActivatedDate))
                {
                    activatedDate = model.ActivatedDate.ToNullDateTime();
                }

                var isExistedInfo = _context
                                    .YachtOtherInformations
                                    .Any(r => r.Deleted == false &&
                                         r.YachtFid == model.YachtFid &&
                                         r.ActivatedDate.GetValueOrDefault().Date == activatedDate.GetValueOrDefault().Date);
                if (isExistedInfo)
                {
                    return(BaseResponse <bool> .NotFound(false));
                }
                var userId = GetUserGuidId();
                var entity = new YachtOtherInformations();
                entity.UniqueId         = UniqueIDHelper.GenarateRandomString(12);
                entity.Title            = model.Title;
                entity.Descriptions     = model.Descriptions;
                entity.InfoTypeFid      = model.InfoTypeFid;
                entity.LanguageFid      = model.LanguageFid;
                entity.FileTypeFid      = model.FileTypeFid;
                entity.FileStreamFid    = model.FileStreamFid;
                entity.IsActivated      = true;
                entity.ActivatedBy      = userId;
                entity.ActivatedDate    = DateTime.Now;
                entity.LastModifiedBy   = userId;
                entity.LastModifiedDate = DateTime.Now;
                entity.CreatedBy        = userId;
                entity.CreatedDate      = DateTime.Now;
                _context.YachtOtherInformations.Add(entity);
                _context.SaveChanges();

                return(BaseResponse <bool> .Success(true));
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }