Example #1
0
        public void CreateWorkOrder(string requestorEmailAddress, DateTime dateTimeReceived, string subject, string workOrderDescription)
        {
            var appUserId = GetAppUserIdByEmail(requestorEmailAddress);
            var workOrder = new WorkOrder()
            {
                CreateDateTime   = dateTimeReceived,
                ModifiedDateTime = dateTimeReceived,
                StatusDateTime   = dateTimeReceived,
                RequestorId      = appUserId,
                LocationId       = appUserId == null ? null : GetLocationIdByAppUserId(appUserId),
                UnitId           = appUserId == null ? null : GetUnitIdByAppUserId(appUserId),
                StatusId         = 1,
                Subject          = subject
            };

            _context.WorkOrders.InsertOnSubmit(workOrder);
            _context.SubmitChanges();

            var workOrderComment = new WorkOrderComment()
            {
                CommentorId    = appUserId,
                CreateDateTime = dateTimeReceived,
                WorkOrderId    = workOrder.Id,
                Comment        = dateTimeReceived + "\n\r" + requestorEmailAddress + "\n\r" + workOrderDescription
            };

            _context.WorkOrderComments.InsertOnSubmit(workOrderComment);
            _context.SubmitChanges();

            SendEmail(workOrder, requestorEmailAddress, workOrderDescription);
        }
 private void detach_WorkOrderComments(WorkOrderComment entity)
 {
     this.SendPropertyChanging();
     entity.AppUser = null;
 }
 private void attach_WorkOrderComments(WorkOrderComment entity)
 {
     this.SendPropertyChanging();
     entity.WorkOrder = this;
 }
 partial void DeleteWorkOrderComment(WorkOrderComment instance);
 partial void UpdateWorkOrderComment(WorkOrderComment instance);
 partial void InsertWorkOrderComment(WorkOrderComment instance);