Ejemplo n.º 1
0
 // DELETE api/<controller>/5
 public void Delete(int id)
 {
     using (var ctx = new TicketEntities())
     {
         var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);
         if (entity != null)
         {
             ctx.tTicket.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 提交数据库变更
 /// </summary>
 /// <param name="dbContext">数据库上下文</param>
 /// <returns></returns>
 protected virtual int SaveDbChanges(TicketEntities dbContext)
 {
     try
     {
         return(dbContext.SaveChanges());
     }
     catch (DbEntityValidationException ex)
     {
         LogDatabaseError(ex);
         throw;
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 3
0
        // PUT api/<controller>/5
        public void Put(int id, [FromBody] tTicket value)
        {
            using (var ctx = new TicketEntities())
            {
                var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);

                if (entity == null)
                {
                    return;
                }

                ctx.tTicket.Attach(value);
                ctx.Entry(value).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 4
0
    /* Module Name: Signup_Click;
     * Student: Mayank Yadav
     * Modification Date: 23-April-2018
     * Description: Insert the record in CLient Table
     * Input/Outputs: Fullname, Username , password, confirm password and other details
     * Globals: No global changes.
     */
    protected void Signup_Click(object sender, EventArgs e)
    {
        TicketEntities te               = new TicketEntities();
        string         fullname         = Fullname.Text;
        string         gender           = Gender.Text;
        string         email            = username.Text;
        string         password         = pass_word.Text;
        string         confirm_password = confirmpassword.Text;
        string         streetaddress1   = StreetAddress1.Text;
        string         streetaddress2   = StreetAddress2.Text;
        string         city             = City.Text;
        string         state            = State.Text;
        string         country          = Country.Text;
        string         zip              = Zip.Text;

        if (fullname != null && email != null && password != null && confirm_password != null && password.Equals(confirm_password))
        {
            Client st = new Client()
            {
                FullName       = fullname,
                Gender         = gender,
                Email          = email,
                Password       = password,
                StreetAddress1 = streetaddress1,
                StreetAddress2 = streetaddress2,
                City           = city,
                State          = state,
                Country        = country,
                Zip            = zip
            };

            te.Clients.Add(st);
            try
            {
                te.SaveChanges();
                Response.Redirect("ClientLogin.aspx");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        else
        {
            Response.Redirect(Request.RawUrl);
        }
    }
Ejemplo n.º 5
0
        public ActionResult Create(Ticket tkt)
        {
            if (ModelState.IsValid)
            {
                MailSender.SendMail("*****@*****.**", tkt.konu, tkt.problem);

                using (TicketEntities TicketDb = new TicketEntities())
                {
                    tkt.name     = Session["Username"].ToString();;
                    tkt.surname  = Session["Surname"].ToString();
                    tkt.SenderId = (int)Session["UserId"];
                    tkt.tarih    = DateTime.Now;
                    tkt.okundu   = 0;
                    TicketDb.Ticket.Add(tkt);
                    TicketDb.SaveChanges();
                }
                ModelState.Clear();
                return(RedirectToAction("CustomerLogin"));
            }
            else
            {
                return(View("CustomerLogin"));
            }
        }
    /* Module Name: LinkButtonCreate_Click;
     * Student: Mayank Yadav
     * Modification Date: 23-April-2018
     * Description: Creates a ticket and store the value in database (Ticket_Master and Ticket_Activity)
     * Input/Outputs: Takes all the required values from form and if successful redirect you to Client Dashboard
     * Globals: No global changes.
     */
    protected void LinkButtonCreate_Click(object sender, EventArgs e)
    {
        string         username = Session["ClientUser"].ToString();
        TicketEntities te       = new TicketEntities();

        Console.WriteLine("Username: "******"Web";
            string Cate_gory     = category.Text;
            string Sub_ject      = subject.Text;
            int    Prior         = 2;;
            string Descript_ion  = Request.Form["description"].ToString();
            if (Full_name != null && Ticket_source != null && Cate_gory != null && Sub_ject != null &&
                Prior != 0 && Descript_ion != null && notBlocked == true)
            {
                byte[]        Byte_prior  = BitConverter.GetBytes(Prior);
                byte          Single_byte = Byte_prior[0];
                Ticket_Master tm          = new Ticket_Master()
                {
                    Email        = E_mail,
                    FullName     = Full_name,
                    CreatedBy    = clientid,
                    CreationDate = DateTime.Now,
                    TicketSource = Ticket_source,
                    Category     = Cate_gory,
                    Subject      = Sub_ject,
                    TicketStatus = "New",
                    Priority     = Single_byte,
                    IsDeleted    = false
                };

                te.Ticket_Master.Add(tm);

                Ticket_Activity ta = new Ticket_Activity()
                {
                    ActivityType = "Create",
                    Summary      = Sub_ject,
                    Description  = Descript_ion,
                    ActivityDate = DateTime.Now,
                    ActedBy      = clientid,
                    ActorName    = "End User",
                    Unread       = false
                };


                tm.Ticket_Activity.Add(ta);
                try
                {
                    te.SaveChanges();
                    Response.Redirect("ClientDashboard.aspx");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
        else
        {
            Response.Redirect("ClientLogin.aspx");
        }
    }