예제 #1
0
        public string AddServices(Vendorservices service)
        {
            var str = string.Empty;

            try
            {
                var userobj = (from u in context.Vendors
                               where u.Vendorid == service.Vendorid
                               select u).FirstOrDefault();

                var wish = (from w in context.Vendorservices
                            where w.Vendorid == service.Vendorid && w.Name == service.Name
                            select w).FirstOrDefault();
                if (userobj == null)
                {
                    return("enter valid data vendor doesnt exist");
                }
                else if (wish != null)
                {
                    return("Vendor has a same service alredy registered");
                }
                else
                {
                    context.Vendorservices.Add(service);
                    context.SaveChanges();
                    str = "sucessfully added service";
                }
            }
            catch (Exception e)
            {
                str = e.Message;
                throw (e);
            }
            return(str);
        }
예제 #2
0
        public string DelServices(Vendorservices services)
        {
            var str = string.Empty;

            try
            {
                var dbcart = (from c in context.Vendorservices
                              where c.Vendorid == services.Vendorid && c.Name == services.Name
                              select c).FirstOrDefault();
                if (dbcart != null)
                {
                    context.Vendorservices.Remove(dbcart);
                    context.SaveChanges();
                    str = "Sucessfully deleted";
                }
                else
                {
                    str = "service doesnt exist for that vendor";
                }
            }
            catch (Exception e)
            {
                str = e.Message;
                throw e;
            };
            return(str);
        }
예제 #3
0
 public string DelServices(Vendorservices services)
 {
     try
     {
         return(VendorDao.DelServices(services));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #4
0
        public string UpdateServices(Vendorservices services)
        {
            string status = "could not update try again";

            try
            {
                Vendorservices carti = (from c in context.Vendorservices
                                        where c.Vendorid == services.Vendorid && c.Name == services.Name
                                        select c).FirstOrDefault();
                carti.Price = services.Price;
                using (var newContext = new StuffyCareContext())
                {
                    newContext.Vendorservices.Update(carti);
                    newContext.SaveChanges();
                    status = "updated sucessfuly";
                }
            }
            catch (Exception e)
            {
                status = "exception occured in Dal";
                throw e;
            }
            return(status);
        }