public BusinessPartnerSubType Post(BusinessPartnerSubType request)
 {
     if (request == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(businessPartnerSubTypeService.AddUpdateBusinessPartnerSubType(request.CreateFrom()).CreateFromm());
 }
Ejemplo n.º 2
0
 /// <summary>
 ///  Create web model from entity
 /// </summary>
 public static ApiModel.BusinessPartnerSubTypeDropDown CreateFrom(this BusinessPartnerSubType source)
 {
     return(new ApiModel.BusinessPartnerSubTypeDropDown
     {
         BusinessPartnerSubTypeId = source.BusinessPartnerSubTypeId,
         BusinessPartnerSubTypeCodeName = source.BusinessPartnerSubTypeCode + " - " + source.BusinessPartnerSubTypeName,
     });
 }
 public Boolean Delete(BusinessPartnerSubType request)
 {
     if (request == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     businessPartnerSubTypeService.DeleteBusinessPartnerSubType(request.BusinessPartnerSubTypeId);
     return(true);
 }
 /// <summary>
 /// Update Business Partner Sub Type Properties while updating the instance
 /// </summary>
 private void UpdateBusinessPartnerSubTypeProperties(BusinessPartnerSubType businessPartnerSubType, BusinessPartnerSubType dbVersion)
 {
     dbVersion.RecLastUpdatedBy                  = businessPartnerSubTypeRepository.LoggedInUserIdentity;
     dbVersion.RecLastUpdatedDt                  = DateTime.Now;
     dbVersion.RowVersion                        = dbVersion.RowVersion + 1;
     dbVersion.BusinessPartnerSubTypeCode        = businessPartnerSubType.BusinessPartnerSubTypeCode;
     dbVersion.BusinessPartnerSubTypeName        = businessPartnerSubType.BusinessPartnerSubTypeName;
     dbVersion.BusinessPartnerSubTypeDescription = businessPartnerSubType.BusinessPartnerSubTypeDescription;
     dbVersion.BusinessPartnerMainTypeId         = businessPartnerSubType.BusinessPartnerMainTypeId;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Crete From web model
 /// </summary>
 public static Cares.Models.DomainModels.BusinessPartnerSubType CreateFrom(this BusinessPartnerSubType source)
 {
     return(new Cares.Models.DomainModels.BusinessPartnerSubType
     {
         BusinessPartnerMainTypeId = source.BusinessPartnerMainTypeId,
         BusinessPartnerSubTypeId = source.BusinessPartnerSubTypeId,
         BusinessPartnerSubTypeCode = source.BusinessPartnerSubTypeCode,
         BusinessPartnerSubTypeName = source.BusinessPartnerSubTypeName,
         BusinessPartnerSubTypeDescription = source.BusinessPartnerSubTypeDescription,
         BusinessPartnerSubTypeKey = source.BusinessPartnerSubTypeKey
     });
 }
        /// <summary>
        /// Delete  Business Partner Sub Type
        /// </summary>
        public void DeleteBusinessPartnerSubType(long businessPartnerSubTypeId)
        {
            BusinessPartnerSubType dbversion = businessPartnerSubTypeRepository.Find((int)businessPartnerSubTypeId);

            CheckBusinessPartnerSubTypeAssociations(businessPartnerSubTypeId);
            if (dbversion == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                                                                  "Business Partner Sub Type with Id {0} not found!", businessPartnerSubTypeId));
            }
            businessPartnerSubTypeRepository.Delete(dbversion);
            businessPartnerSubTypeRepository.SaveChanges();
        }
        /// <summary>
        /// Add / Update Business Partner Sub Type
        /// </summary>
        public BusinessPartnerSubType AddUpdateBusinessPartnerSubType(BusinessPartnerSubType businessPartnerSubType)
        {
            BusinessPartnerSubType dbVersion = businessPartnerSubTypeRepository.Find(businessPartnerSubType.BusinessPartnerSubTypeId);

            if (businessPartnerSubTypeRepository.BusinessPartnerSubTypeCodeDuplicationCheck(businessPartnerSubType))
            {
                throw new CaresException(Resources.BusinessPartner.BusinessPartnerSubType.BusinessPartnerSubTypeCodeDuplicationError);
            }

            if (dbVersion != null)
            {
                UpdateBusinessPartnerSubTypeProperties(businessPartnerSubType, dbVersion);
                businessPartnerSubTypeRepository.Update(dbVersion);
            }
            else
            {
                dbVersion = new BusinessPartnerSubType();
                SetBusinessPartnerSubTypeProperties(businessPartnerSubType, dbVersion);
                businessPartnerSubTypeRepository.Add(dbVersion);
            }
            businessPartnerSubTypeRepository.SaveChanges();
            // To Load the proprties
            return(businessPartnerSubTypeRepository.LoadBusinessPartnerSubTypeWithDetail(dbVersion.BusinessPartnerSubTypeId));
        }