Exemple #1
0
        public async Task<IActionResult> AddLocation(Location location)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            _context.Location.Add(location);
            await _context.SaveChangesAsync();

            return CreatedAtAction("GetLocation", new { id = location.ID }, location);
        }
        public async Task <IActionResult> AddCategory(Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            category.CreatedDate = DateTime.Now;
            category.CreatedBy   = User.Identity.Name;
            _context.Category.Add(category);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategory", new { id = category.ID }, category));
        }
        public async Task <IActionResult> AddLocation(Location location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            location.CreatedDate = DateTime.Now;
            location.CreatedBy   = User.Identity.Name;
            _context.Location.Add(location);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLocation", new { id = location.ID }, location));
        }
        public async Task <IActionResult> AddAsset(Asset Asset)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Asset.CreatedDate = DateTime.Now;
            Asset.CreatedBy   = User.Identity.Name;
            _context.Asset.Add(Asset);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAsset", new { id = Asset.ID }, Asset));
        }
Exemple #5
0
        public async Task <IActionResult> AddMoveAssetRequest(MoveAssetViewModel moveRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Movement movement = new Movement
            {
                MovementDate = moveRequest.MovementDate,
                Description  = moveRequest.Description,
                Status       = "Order",
                LocationID   = moveRequest.LocationID,
                ApprovedBy   = null,
                CreatedBy    = User.Identity.Name,
                CreatedDate  = DateTime.Now
            };

            _context.Movement.Add(movement);

            foreach (var item in moveRequest.ListAssetID)
            {
                MovementItem movementItem = new MovementItem
                {
                    MovementID  = movement.ID,
                    AssetID     = item,
                    IsMoved     = false,
                    CreatedBy   = User.Identity.Name,
                    CreatedDate = DateTime.Now
                };

                _context.MovementItem.Add(movementItem);
            }

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMove", new { id = movement.ID }, movement));
        }