Exemple #1
0
        /// <summary>
        /// Add /Update Rating Type
        /// </summary>
        public BpRatingType SaveRatingType(BpRatingType bpRatingType)
        {
            BpRatingType dbVersion = bpRatingTypeRepository.Find(bpRatingType.BpRatingTypeId);

            //Code Duplication Check
            if (bpRatingTypeRepository.DoesRatingTypeCodeExist(bpRatingType))
            {
                throw new CaresException(Resources.BusinessPartner.RatingType.RatingTypeCodeDuplicationError);
            }

            if (dbVersion != null)
            {
                UpdateRatingTypePropertie(bpRatingType, dbVersion);
                bpRatingTypeRepository.Update(dbVersion);
            }
            else
            {
                dbVersion = new BpRatingType();
                SetRatingTypeProperties(bpRatingType, dbVersion);
                bpRatingTypeRepository.Add(dbVersion);
            }
            bpRatingTypeRepository.SaveChanges();
            // To Load the proprties
            return(bpRatingTypeRepository.Find(dbVersion.BpRatingTypeId));
        }
 public BpRatingType Post(BpRatingType area)
 {
     if (area == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(ratingTypeService.SaveRatingType(area.CreateFrom()).CreateFromm());
 }
 public Boolean Delete(BpRatingType bpRatingType)
 {
     if (bpRatingType == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     ratingTypeService.DeleteRatingType(bpRatingType.BpRatingTypeId);
     return(true);
 }
Exemple #4
0
 /// <summary>
 /// update Rating Type object Properties in case of updation
 /// </summary>
 private void UpdateRatingTypePropertie(BpRatingType ratingType, BpRatingType dbVersion)
 {
     dbVersion.RecLastUpdatedBy        = bpRatingTypeRepository.LoggedInUserIdentity;
     dbVersion.RecLastUpdatedDt        = DateTime.Now;
     dbVersion.RowVersion              = dbVersion.RowVersion + 1;
     dbVersion.BpRatingTypeCode        = ratingType.BpRatingTypeCode;
     dbVersion.BpRatingTypeName        = ratingType.BpRatingTypeName;
     dbVersion.BpRatingTypeDescription = ratingType.BpRatingTypeDescription;
 }
Exemple #5
0
 /// <summary>
 /// Set newly created Rating Type object Properties in case of adding
 /// </summary>
 private void SetRatingTypeProperties(BpRatingType ratingType, BpRatingType dbVersion)
 {
     dbVersion.RecLastUpdatedBy        = dbVersion.RecCreatedBy = bpRatingTypeRepository.LoggedInUserIdentity;
     dbVersion.RecLastUpdatedDt        = dbVersion.RecCreatedDt = DateTime.Now;
     dbVersion.BpRatingTypeCode        = ratingType.BpRatingTypeCode;
     dbVersion.BpRatingTypeName        = ratingType.BpRatingTypeName;
     dbVersion.BpRatingTypeDescription = ratingType.BpRatingTypeDescription;
     dbVersion.UserDomainKey           = bpRatingTypeRepository.UserDomainKey;
 }
Exemple #6
0
 /// <summary>
 ///  Create web model from entity
 /// </summary>
 public static Models.BpRatingType CreateFromm(this BpRatingType source)
 {
     return(new Models.BpRatingType
     {
         BpRatingTypeId = source.BpRatingTypeId,
         BpRatingTypeCode = source.BpRatingTypeCode,
         BpRatingTypeName = source.BpRatingTypeName,
         BpRatingTypeDescription = source.BpRatingTypeDescription
     });
 }
Exemple #7
0
        /// <summary>
        /// Delete Rating Type by id
        /// </summary>
        public void DeleteRatingType(long ratingTypeId)
        {
            BpRatingType dbversion = bpRatingTypeRepository.Find((int)ratingTypeId);

            ValidateBeforeDeletion(ratingTypeId);
            if (dbversion == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                                                                  "Rating Type with Id {0} not found!", ratingTypeId));
            }
            bpRatingTypeRepository.Delete(dbversion);
            bpRatingTypeRepository.SaveChanges();
        }