Пример #1
0
        public string SetOrderStatus(DUETContext db, int id, string status)
        {
            try
            {
                var member = this as Member;
                if (member == null)
                {
                    return("Error: Member unknown.");
                }
                else
                {
                    var order = db.Orders.SingleOrDefault(o => o.Id == id);
                    if (order != null)
                    {
                        if (status == "Payed")
                        {
                            order.Payed   = true;
                            order.PayDate = DateTime.Now;
                        }
                        else if (status == "Processed")
                        {
                            order.Processed     = true;
                            order.ProcessedDate = DateTime.Now;
                        }

                        else if (status == "Shipped")
                        {
                            order.Shipped     = true;
                            order.ShippedDate = DateTime.Now;
                        }
                        else if (status == "Ready")
                        {
                            order.Ready     = true;
                            order.ReadyDate = DateTime.Now;
                        }
                        db.Orders.Update(order);
                        db.SaveChanges();
                        return("");
                    }
                    else
                    {
                        return("Error: Order Unknown.");
                    }
                }
            }
            catch (Exception exception)
            {
                return("Error 39:" + exception.Message);
            }
        }
Пример #2
0
        public string ConfirmOrder(DUETContext db, dynamic data)
        {
            try
            {
                var member = this as Member;
                if (member == null)
                {
                    return("Error: Member unknown.");
                }
                else
                {
                    int id      = data.orderid;
                    var anorder = db.Orders.SingleOrDefault(o => o.Id == id);
                    if (anorder == null)
                    {
                        return("Error: order unknown");
                    }
                    else
                    {
                        anorder.Sample        = (data.ordertype == "sample") ? true : false;
                        anorder.Fabric        = (data.ordertype == "fabric") ? true : false;
                        anorder.Meters        = data.meters;
                        anorder.Photo         = (data.ordertype == "photo") ? true : false;
                        anorder.Photosize     = data.photosize;
                        anorder.DeliveryType  = data.deliverytype;
                        anorder.OrderCost     = data.costorder;
                        anorder.DeliveryCost  = data.costdelivery;
                        anorder.BTW           = data.btw;
                        anorder.Total         = data.total;
                        anorder.OrderDate     = DateTime.Now;
                        anorder.ProcessedDate = DateTime.Now.AddDays(App.PROCESDAYS);
                        anorder.Confirmed     = true;

                        db.Orders.Update(anorder);
                        db.SaveChanges();
                        return("");
                    }
                }
            }
            catch (Exception exception)
            {
                return("Error 37:" + exception.Message);
            }
        }
Пример #3
0
        public string Login(DUETContext db, dynamic data)
        {
            try
            {
                string email  = data.email;
                var    member = db.Members.FirstOrDefault(m => m.Email == email);

                if (member == null)
                {
                    return("Error: Emailaddress unknown.");
                }
                else
                {
                    string password = data.password;
                    if (member.Password == password)
                    {
                        member.Visits += 1;
                        db.Members.Update(member);
                        db.SaveChanges();

                        string GUID = data.GUID;
                        Visitors.TryUpdate(GUID, member, this);

                        return(member.Name);
                    }
                    else
                    {
                        return("Error: Password unkown.");
                    }
                }
            }
            catch
            {
                return("Error: Sorry, something went wrong. Please try again. <br/>");
            }
        }
Пример #4
0
        public string Register(DUETContext db, dynamic data)
        {
            try
            {
                string email  = data.email;
                var    member = db.Members.FirstOrDefault(m => m.Email == email);

                if (member == null)
                {
                    member          = new Member();
                    member.GUID     = this.GUID;
                    member.Name     = data.name;
                    member.Email    = data.email;
                    member.Password = data.password;
                    member.Phone    = data.phone;
                    member.Address  = data.address;
                    member.Zipcode  = data.zipcode;
                    member.City     = data.city;
                    string country = data.country;
                    country = country.ToUpper();
                    if (country == "" || country == "NETHERLANDS" || country == "NETHERLAND" || country == "NEDERLANDS")
                    {
                        country = "NEDERLAND";
                    }
                    member.Country   = country;
                    member.StartDate = DateTime.Now;

                    db.Members.Add(member);
                    db.SaveChanges();

                    return(Login(db, data));
                }
                else
                {
                    if (member.Password == data.password)
                    {
                        member.Name     = data.name;
                        member.Email    = data.email;
                        member.Password = data.password;
                        member.Phone    = data.phone;
                        member.Address  = data.address;
                        member.Zipcode  = data.zipcode;
                        member.City     = data.city;
                        string country = data.country;
                        country = country.ToUpper();
                        if (country == "" || country == "NETHERLANDS" || country == "NETHERLAND" || country == "NEDERLANDS")
                        {
                            country = "NEDERLAND";
                        }
                        member.Country = country;

                        db.Members.Update(member);
                        db.SaveChanges();

                        return(Login(db, data));
                    }
                    else
                    {
                        return("Error: Password unknown.");
                    }
                }
            }
            catch (Exception exception)
            {
                return("Error:" + exception.Message);
            }
        }