Example #1
0
        /// <summary>
        /// Add property and the required first communication record.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="operatorId"></param>
        /// <returns></returns>
        public async Task <PropertyViewModel> AddPropertyAsync(PropertyAndCommunicationCreateModel model, User theOperator)
        {
            var property = Mapper.Map <Property>(model);

            using (var t = _propertyDataService.BeginTransaction())
            {
                await _propertyDataService.AddAsync(property);

                var communication = new Communication()
                {
                    Property = property, PropertyId = property.Id, Content = model.FirstCommunication
                };
                await _communicationDataService.AddAsync(communication, true, theOperator);

                t.Commit();
            }

            if (property.CreatorId != default(int))
            {
                await _snsService.EmailNotifyAsync(property.CreatorId, Resources.Property.EmailSubjectForCreation.FormatMe(property.Name),
                                                   Resources.Property.EmailContentForCreation.FormatMe(property.CreatorId, property.Name, property.CreateTime));
            }

            var toReturn = Mapper.Map <PropertyViewModel>(property);

            return(toReturn);
        }
Example #2
0
        public async Task <IHttpActionResult> Post(PropertyAndCommunicationCreateModel model)
        {
            var toReturn = await _propertyService.AddPropertyAsync(model, this.GetOperator(_userService));

            return(CreatedAtRoute("property", new { id = toReturn.Id }, toReturn));
        }