Example #1
0
        public async Task <BaseResponseModel> Edit(AspiceVersionModel request)
        {
            BaseResponseModel response = new BaseResponseModel();

            if (request.Validate())
            {
                AspiceVersion aspiceVersion = await Load(request.Id, response);

                if (aspiceVersion != null)
                {
                    aspiceVersion.ReleaseDate   = request.ReleaseDate;
                    aspiceVersion.Description   = request.Description;
                    aspiceVersion.VersionNumber = request.VersionNumber;

                    await Database.SaveChangesAsync();

                    response.Message = "Automotive SPICE version was successfully edited!";
                }
            }
            else
            {
                response.Success = false;
                response.Message = "Some of the required properties is not present!";
            }

            return(response);
        }
Example #2
0
        public async Task <BaseResponseModelPost> Create(AspiceVersionModel request)
        {
            BaseResponseModelPost response = new BaseResponseModelPost();

            if (request.Validate())
            {
                AspiceVersion aspiceVersion = new AspiceVersion
                {
                    ReleaseDate   = request.ReleaseDate,
                    Description   = request.Description,
                    VersionNumber = request.VersionNumber
                };

                await Database.AspiceVersion.AddAsync(aspiceVersion);

                await Database.SaveChangesAsync();

                response.Id      = aspiceVersion.Id;
                response.Message = "Automotive SPICE version was successfully created!";
            }
            else
            {
                response.Success = false;
                response.Message = "Some of the required properties is not present!";
            }

            return(response);
        }
Example #3
0
        public async Task <BaseResponseModel> Drop(int id)
        {
            BaseResponseModel response = new BaseResponseModel();

            AspiceVersion aspiceVersion = await Load(id, response);

            if (aspiceVersion != null)
            {
                if (aspiceVersion.AspiceProcess.Count == 0)
                {
                    Database.AspiceVersion.Remove(aspiceVersion);

                    await Database.SaveChangesAsync();

                    response.Message = "Automotive SPICE version was successfully deleted!";
                }
                else
                {
                    response.Success = false;
                    response.Message = "Cannot delete Automotive SPICE version, because some Automotive SPICE process use this version!";
                }
            }

            return(response);
        }
Example #4
0
 public AspiceVersionModel ConvertToModel(AspiceVersion dbModel)
 {
     return(new AspiceVersionModel
     {
         Id = dbModel.Id,
         ReleaseDate = dbModel.ReleaseDate,
         Description = dbModel.Description,
         VersionNumber = dbModel.VersionNumber
     });
 }
Example #5
0
        public async Task <AspiceVersion> Load(int id, BaseResponseModel response, bool tracking = true, bool lazy = true)
        {
            AspiceVersion aspiceVersion = await Database.AspiceVersion.FirstOrDefaultAsyncSpecial(a => a.Id == id, tracking);

            if (aspiceVersion == null)
            {
                response.Success = false;
                response.Message = "Unknown Automotive SPICE version!";
            }

            return(aspiceVersion);
        }
Example #6
0
        public async Task <BaseResponseModelGet <AspiceVersionModel> > Get(int id, bool lazy)
        {
            var response = new BaseResponseModelGet <AspiceVersionModel>();

            AspiceVersion aspiceVersion = await Load(id, response, false);

            if (aspiceVersion != null)
            {
                response.Value = ConvertToModel(aspiceVersion);
            }

            return(response);
        }