Esempio n. 1
0
 public IHttpActionResult Put(int id, Dto.Photo photo)
 {
     photo.ValidateNotNullParameter("photo");
     RestStatus status;
     Dto.Photo dto = this.StoreService.EditPhoto(id, photo.Description, out status);
     return RestfulPut(status, dto);
 }
 public static Dmn.Customer ToNewDmn(Dto.Customer dataObject)
 {
     return new Dmn.Customer(dataObject.Name)
     {
         ContactInfo = dataObject.ContactInfo,
         PreferredCommunicationMethod = dataObject.PreferredCommunicationMethod
     };
 }
 public IHttpActionResult Post(Dto.Issue issueData)
 {
     Issue issue = IssueConverter.ToNewDmn(issueData);
     issue.DateRaised = System.DateTime.Now;
     this.context.Issues.Add(issue);
     this.context.SaveChanges();
     return this.Created(this.Request.RequestUri.AbsolutePath + "/" + issue.Id, IssueConverter.ToDto(issue));
 }
Esempio n. 4
0
 public IHttpActionResult Post(Dto.Photo photo)
 {
     photo.ValidateNotNullParameter("photo");
     RestStatus status;
     Dto.Photo dto = this.StoreService.CreatePhoto(photo.Description, photo.Url, out status);
     string location = String.Format("{0}/{1}", this.Request.RequestUri, photo.Id);
     return RestfulPost(status, location, dto);
 }
Esempio n. 5
0
        public IHttpActionResult Post(Dto.Ticket ticket)
        {
            Dmn.Ticket newTicket = new Dmn.Ticket(ticket.ClientId, ticket.Title, ticket.Description, ticket.TicketType);

            Context.Tickets.Add(newTicket);
            Context.SaveChanges();
            return Created(this.Request.RequestUri.AbsolutePath + "/" + ticket.Id, TicketConverter.ToDto(newTicket));
        }
Esempio n. 6
0
 public IHttpActionResult Put(Dto.Store store)
 {
     store.ValidateNotNullParameter("store");
     RestStatus status;
     Dto.Store dto = this.StoreService.EditStore(new WeekSchedule(store.Hours), store.PhoneNumber, store.StreetAddress, store.City, store.State, store.Zip,
     store.Directions, store.Email, store.FacebookUrl, store.TwitterUrl, store.GooglePlusUrl, store.InstagramUrl,
     store.PinterestUrl, store.YoutubeUrl, store.Home, store.About, store.Contact, out status);
     return RestfulPut(status, dto);
 }
 public static void PutInDomain(Dto.Team teamData, Dmn.Team team)
 {
     Dmn.EarlyBirdsContext context = new Dmn.EarlyBirdsContext();
     team.Name = teamData.Name;
     team.TeamMembers.Clear();
     team.Expertise.Clear();
     foreach (Dmn.TypeOfIssue field in teamData.Expertise)
     {
         team.Expertise.Add(field);
     }
     team.AddTeamMembers(context.Agents.Where(i => teamData.TeamMemberIds.Contains(i.Id)));
 }
 public static Dmn.Issue ToNewDmn(Dto.Issue dataObject)
 {
     Dmn.EarlyBirdsContext context = new Dmn.EarlyBirdsContext();
     Dmn.Issue output = new Dmn.Issue(dataObject.Name,
        dataObject.WebsiteId, dataObject.Priority,
         dataObject.IssueType, dataObject.Description)
     {
         TeamId = dataObject.AssignedTeamId,
     };
     //output.AddAffectedCustomers(Dmn.DatabaseTest.SampleCompany.CustomerAccounts.Where(i => dataObject.AffectedCustomersIds.Contains(i.Id)));
     //output.AddAffectedBrowsers(dataObject.AffectedBrowsers);
     return output;
 }
Esempio n. 9
0
 public IHttpActionResult Put(int ticketId, Dto.Ticket response)
 {
     Ticket ticket = Context.Tickets.FirstOrDefault(i => i.Id == ticketId);
     if (ticket == null)
     {
         return NotFound();
     }
     else
     {
         ticket.Edit(response.Response);
         Context.SaveChanges();
         return Ok(TicketConverter.ToDto(ticket));
     }
 }
 public IHttpActionResult Post(Dto.Message message)
 {
     if (message == null)
     {
         return this.BadRequest();
     }
     else
     {
         Message newMessage = new Message(message.SenderId, message.RecipientId, message.Content);
         this.Context.Messages.Add(newMessage);
         this.Context.SaveChanges();
         newMessage = this.Context.Messages.FirstOrDefault(i => i.Id == newMessage.Id);
         return this.Created("", new {});
     }
 }
        public static void PutInDomain(Dto.Issue issueData, Dmn.Issue issue)
        {
            Dmn.EarlyBirdsContext context = new Dmn.EarlyBirdsContext();

            //issue.AffectedBrowsers.Clear();
            issue.AffectedCustomers.Clear();
            issue.Notes.Clear();
            issue.Name = issueData.Name;
            issue.WebsiteId = issueData.WebsiteId;
            issue.Priority = issueData.Priority;
            issue.IssueType = issueData.IssueType;
            issue.Description = issueData.Description;
            issue.Open = issueData.Open;
            issue.TeamId = issueData.AssignedTeamId;
            issue.AddAffectedCustomers(context.Customers.Where(i => issueData.AffectedCustomersIds.Contains(i.Id)));
            issue.AddNotes(issueData.Notes);
        }
 public static Dmn.Team ToNewDmn(Dto.Team dataObject)
 {
     Dmn.EarlyBirdsContext context = new Dmn.EarlyBirdsContext();
     Dmn.Team output = new Dmn.Team(dataObject.Name);
     if (dataObject.TeamMemberIds != null)
     {
         output.AddTeamMembers(context.Agents.Where(i => dataObject.TeamMemberIds.Contains(i.Id)));
     }
     if (dataObject.Expertise != null)
     {
         foreach (Dmn.TypeOfIssue field in dataObject.Expertise)
         {
             output.Expertise.Add(field);
         }
     }
     return output;
 }
Esempio n. 13
0
 public IHttpActionResult Put(int id, Dto.Ticket ticket)
 {
     Dmn.Ticket existing = Context.Tickets.FirstOrDefault(i => i.Id == id);
     if (existing == null)
     {
         return NotFound();
     }
     else if (existing.Status == TicketStatus.Processed)
     {
         return BadRequest();
     }
     else
     {
         existing.UpdateTicket(ticket.AssignedToUserId, ticket.Priority, ticket.Title, ticket.Description, ticket.Solution, ticket.TicketType, ticket.Status);
         Context.SaveChanges();
         return Ok(TicketConverter.ToDto(existing));
     }
 }
 public IHttpActionResult Post(Dto.Account account)
 {
     if (account == null)
     {
         return this.BadRequest();
     }
     else
     {
         Business existingBusiness = this.Context.Businesses.ToList().FirstOrDefault(i => i.Id == account.BusinessId);
         if (existingBusiness == null)
         {
             return this.BadRequest();
         }
         else
         {
             Account newUser = existingBusiness.CreateNewAccount(account.FirstName, account.LastName, account.Email, account.Password, account.Admin);
             this.Context.Users.Add(newUser);
             this.Context.SaveChanges();
             return this.Created(this.Request.RequestUri.AbsolutePath + "/" + newUser.Id, AccountConverter.ToDto(newUser));
         }
     }
 }
Esempio n. 15
0
 public IHttpActionResult Post(Dto.Ticket ticket)
 {
     if (ticket == null)
     {
         return this.BadRequest();
     }
     else
     {
         TicketCategory existingTicketCategory = this.Context.TicketCategories.ToList().FirstOrDefault(i => i.Id == ticket.CategoryId);
         Business existingBusiness = this.Context.Businesses.ToList().FirstOrDefault(i => i.Id == existingTicketCategory.BusinessId);
         User existingUser = this.Context.Users.ToList().FirstOrDefault(i => i.Id == ticket.CreatorId);
         if (existingTicketCategory == null || existingBusiness == null || existingUser == null)
         {
             return this.BadRequest();
         }
         else
         {
             Ticket newTicket = existingBusiness.CreateNewTicket(ticket.Title, ticket.Content, existingTicketCategory.Id, ticket.Priority, ticket.CreatorId);
             this.Context.Tickets.Add(newTicket);
             this.Context.SaveChanges();
             return this.Created(this.Request.RequestUri.AbsolutePath + "/" + newTicket.Id, TicketConverter.ToDto(newTicket));
         }
     }
 }
        public IHttpActionResult Post(Dto.TicketCategory category)
        {
            if (category == null)
            {
                return this.BadRequest();
            }
            else
            {
                Business existingBusiness = this.Context.Businesses.ToList().FirstOrDefault(i => i.Id == category.BusinessId);

                if (existingBusiness == null)
                {
                    return this.BadRequest();
                }
                else
                {
                    TicketCategory newTicketCategory = existingBusiness.CreateNewTicketCategory(category.Name);
                    this.Context.TicketCategories.Add(newTicketCategory);
                    this.Context.SaveChanges();

                    return this.Created(this.Request.RequestUri.AbsolutePath + "/" + newTicketCategory.Id, TicketCategoryConverter.ToDto(newTicketCategory));
                }
            }
        }
Esempio n. 17
0
 public IHttpActionResult Post(Dto.Department department)
 {
     department.ValidateNotNullParameter("department");
     RestStatus status;
     Dto.Department dto = this.EditService.CreateDepartment(department.Name, department.Description, department.ImageUrl, out status);
     string location = String.Format("{0}/{1}", this.Request.RequestUri, department.Id);
     return RestfulPost(status, location, dto);
 }
Esempio n. 18
0
 public IHttpActionResult Put(int id, Dto.Department department)
 {
     department.ValidateNotNullParameter("department");
     RestStatus status;
     Dto.Department dto = this.EditService.EditDepartment(id, department.Name, department.Description, department.ImageUrl, out status);
     return RestfulPut(status, dto);
 }
Esempio n. 19
0
 public IHttpActionResult Post(Dto.Message message)
 {
     Context.Messages.Add(new Message(message.Text, message.UserId, message.ChatLogId));
     Context.SaveChanges();
     return Created(this.Request.RequestUri.AbsolutePath + "/" + message.Id, message);
 }
Esempio n. 20
0
 public IHttpActionResult Put(int id, Dto.Product product)
 {
     product.ValidateNotNullParameter("product");
     RestStatus status;
     Dto.Product dto = this.EditService.EditProduct(id, product.CategoryId, product.Name, product.Description, GetPrice(product), product.ImageUrl, out status);
     return RestfulPut(status, dto);
 }
Esempio n. 21
0
 public IHttpActionResult Post(Dto.Product product)
 {
     product.ValidateNotNullParameter("product");
     RestStatus status;
     Dto.Product dto = this.EditService.CreateProduct(product.CategoryId, product.Name, product.Description, GetPrice(product), product.ImageUrl, out status);
     string location = String.Format("{0}/{1}", this.Request.RequestUri, product.Id);
     return RestfulPost(status, location, dto);
 }
 public IHttpActionResult Post(Dto.Team teamData)
 {
     Team team = TeamConverter.ToNewDmn(teamData);
     if (team != null)
     {
         this.context.Teams.Add(team);
         this.context.SaveChanges();
         return this.Created(this.Request.RequestUri.AbsolutePath + "/" + team.Id, TeamConverter.ToDto(team));
     }
     else
     {
         return this.BadRequest();
     }
 }
 public IHttpActionResult Post(Dto.Business business)
 {
     if (business == null)
     {
         return this.BadRequest();
     }
     else
     {
         Business newBusiness = new Business(business.Name, business.Email, business.Password);
         this.Context.Businesses.Add(newBusiness);
         this.Context.SaveChanges();
         return this.Created(this.Request.RequestUri.AbsolutePath + "/" + newBusiness.Id, BusinessConverter.ToDto(newBusiness));
     }
 }
 public IHttpActionResult Put(int id, Dto.Agent agentData)
 {
     Agent existing = this.context.Agents.FirstOrDefault(i => i.Id == id);
     if (existing == null)
     {
         return this.NotFound();
     }
     else
     {
         AgentConverter.PutInDomain(agentData, existing);
         this.context.SaveChanges();
         return this.Ok(AgentConverter.ToDto(existing));
     }
 }
 public IHttpActionResult Post(Dto.Agent agentData)
 {
     Agent agent = AgentConverter.ToNewDmn(agentData);
     this.context.Agents.Add(agent);
     this.context.SaveChanges();
     return this.Created(this.Request.RequestUri.AbsolutePath + "/" + agent.Id, AgentConverter.ToDto(agent));
 }
Esempio n. 26
0
 public IHttpActionResult Put(int ticketId, Dto.Ticket ticket)
 {
     if (ticket == null)
     {
         return this.BadRequest();
     }
     else
     {
         Ticket existingTicket = this.Context.Tickets.ToList().FirstOrDefault(i => i.Id == ticketId);
         if (existingTicket == null)
         {
             return this.NotFound();
         }
         else
         {
             existingTicket.UpdateTicket(ticket.Title, ticket.CategoryId, ticket.Priority, ticket.Status);
             this.Context.SaveChanges();
             return this.Ok(TicketConverter.ToDto(existingTicket));
         }
     }
 }
 public IHttpActionResult Put(int id, Dto.Team teamData)
 {
     Team existing = this.context.Teams.FirstOrDefault(i => i.Id == id);
     if (existing == null)
     {
         return this.NotFound();
     }
     else
     {
         TeamConverter.PutInDomain(teamData, existing);
         this.context.SaveChanges();
         return this.Ok(TeamConverter.ToDto(existing));
     }
 }
 public IHttpActionResult PostAddTeamMember(int teamId, Dto.Agent agentData)
 {
     Team team = this.context.Teams.FirstOrDefault(i => i.Id == teamId);
     Agent agent = this.context.Agents.FirstOrDefault(i => i.Id == agentData.Id);
     if (team == null || agent == null)
     {
         return this.NotFound();
     }
     else
     {
         team.TeamMembers.Add(agent);
         return this.Created(this.Request.RequestUri.AbsolutePath + "/" + teamId, TeamConverter.ToDto(team));
     }
 }
        public IHttpActionResult Put(int businessId, Dto.Business business)
        {
            if (business == null)
            {
                return this.BadRequest();
            }
            else
            {
                Business existingBusiness = this.Context.Businesses.ToList().FirstOrDefault(i => i.Id == businessId);

                if (existingBusiness == null)
                {
                    return this.NotFound();
                }
                else
                {
                    existingBusiness.UpdateBusiness(business.Name, business.Email, business.Password);
                    this.Context.SaveChanges();
                    return this.Ok(BusinessConverter.ToDto(existingBusiness));
                }
            }
        }
Esempio n. 30
0
 private static Price GetPrice(Dto.Product product)
 {
     product.ValidateNotNullParameter("product");
     Price price = product.ExactPrice.HasValue ? new Price(product.ExactPrice.Value) : new Price(product.FromPrice ?? 0, product.ToPrice ?? 0);
     return price;
 }