public IHttpActionResult UpdateAssetAllocations(AvailableAssetsModel assetAllocationArray)
        {
            string rtnMsg = string.Empty;

            try
            {
                if (assetAllocationArray.AssetAllocationArray.Count > 0 && assetAllocationArray.AssetId > 0)
                {
                    AssetAllocation assetAllocation = db.AssetAllocations.Where(x => x.AssetId == assetAllocationArray.AssetId).FirstOrDefault();
                    assetAllocation.LocationId         = assetAllocationArray.AssetAllocationArray.FirstOrDefault().LocationId;
                    assetAllocation.EmployeeId         = assetAllocationArray.AssetAllocationArray.FirstOrDefault().EmployeeId;
                    assetAllocation.AssetAllocatedOn   = System.DateTime.Now;
                    assetAllocation.AssetCanceledOn    = null;
                    assetAllocation.CreatedOn          = System.DateTime.Now;
                    assetAllocation.CreatedBy          = assetAllocationArray.CreatedBy;
                    assetAllocation.AllocationComments = assetAllocationArray.AssetAllocationArray.FirstOrDefault().Comments;
                    db.AssetAllocations.Add(assetAllocation);
                    db.Entry(assetAllocation).State = EntityState.Modified;
                    db.SaveChanges();
                    rtnMsg = "Inserted";
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(rtnMsg));
        }
示例#2
0
 public AssetsAvailabilityRequest(AvailableAssetsModel availableAssetsModel, AvailabilityQueryParamaters availabilityQueryParamaters, Guid tenatnId)
 {
     AvailableAssetsModel        = availableAssetsModel;
     AvailabilityQueryParamaters = availabilityQueryParamaters;
     TenantId = tenatnId;
 }