public static MerchantModel ToModel(this MerchantPO item)
 {
     if (item == null)
     {
         return(null);
     }
     return(new MerchantModel
     {
         Id = item.Id,
         Name = item.Name,
         Shortname = item.Shortname,
         Branch = item.Branch,
         Logo = item.Logo,
         Introduction = item.Introduction,
         Contact = item.Contact,
         Telphone = item.Telphone,
         Mobliephone = item.Mobliephone,
         Businesslicence = item.Businesslicence,
         Legalperson = item.Legalperson,
         DistrictId = item.DistrictId,
         Address = item.Address,
         Longitude = item.Longitude,
         Latitude = item.Latitude,
         Cash = item.Cash,
         Point = item.Point,
         Status = item.Status,
         Createtime = item.Createtime,
         Updatetime = item.Updatetime,
     });
 }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static MerchantPO GetDataForSave(int id)
        {
            MerchantPO item;

            if (id == 0)
            {
                item = new MerchantPO()
                {
                    Name            = "",
                    Shortname       = "",
                    Branch          = "",
                    Logo            = "",
                    Introduction    = "",
                    Contact         = "",
                    Telphone        = "",
                    Mobliephone     = "",
                    Businesslicence = "",
                    Legalperson     = "",
                    DistrictId      = 0,
                    Address         = "",
                    Longitude       = 0,
                    Latitude        = 0,
                    Cash            = 0,
                    Point           = 0,
                    Status          = 0,
                    Createtime      = DateTime.Now,
                    Updatetime      = DateTime.Now,
                };
            }
            else
            {
                item = GetItem(id);
            }
            return(item);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool Delete(int id)
        {
            var item = new MerchantPO {
                Id = id
            };

            return(Delete(item));
        }
Esempio n. 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool Delete(MerchantPO item)
 {
     using (var context = new SchoolContext())
     {
         context.Merchants.Attach(item);
         context.Merchants.Remove(item);
         context.SaveChanges();
     }
     return(true);
 }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool Save(MerchantPO item)
 {
     using (var context = new SchoolContext())
     {
         if (item.Id == 0)
         {
             context.Merchants.Add(item);
         }
         else
         {
             context.Entry(item).State = EntityState.Modified;
         }
         context.SaveChanges();
     }
     return(true);
 }