예제 #1
0
        /// <summary>
        /// Function to delete entity whose primary key is passes.
        /// </summary>
        /// <param name="pk">Primary key of entity to be deleted</param>
        /// <param name="context">context to maintain transaction</param>
        public void Delete(object pk, StandardEngEntities context)
        {
            DbSet <T> table    = context.Set <T>();
            T         existing = table.Find(pk);

            context.Entry(existing).State = EntityState.Deleted;
        }
예제 #2
0
        /// <summary>
        /// Function to update entity.
        /// </summary>
        /// <param name="entity">entity to be updated</param>
        /// <param name="context">context to maintain transaction</param>
        public void Update(T entity, StandardEngEntities context)
        {
            DbSet <T> table = context.Set <T>();

            table.Attach(entity);
            context.Entry(entity).State = EntityState.Modified;
        }
        public static void GetListOfWarrantyExpiry()
        {
            List <GetWarrantyExpiryCustomerList_Result> listExpitry = new List <GetWarrantyExpiryCustomerList_Result>();

            using (StandardEngEntities context = BaseContext.GetDbContext())
            {
                listExpitry = context.GetWarrantyExpiryCustomerList().Where(m => m.IsReadyForAMC == false).ToList();

                if (listExpitry.Count > 0)
                {
                    string bodyTemplate = System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/Template/WarrantyExpiryReminder.html"));

                    foreach (GetWarrantyExpiryCustomerList_Result obj in listExpitry)
                    {
                        tblCommissioning commisioningObj = new tblCommissioning();
                        bodyTemplate = bodyTemplate.Replace("[@CustomerName]", obj.CustomerName);
                        bodyTemplate = bodyTemplate.Replace("[@MachineModel]", obj.MachineName);
                        bodyTemplate = bodyTemplate.Replace("[@MachineType]", obj.MachineTypeName);
                        bodyTemplate = bodyTemplate.Replace("[@MachineSerialNo]", obj.MachineSerialNo);
                        bodyTemplate = bodyTemplate.Replace("[@ExpiryDate]", obj.WarrantyExpireDate);

                        Task task = new Task(() => EmailHelper.SendAsyncEmail(obj.CustomerEmail, "Machine Warranty Expiry Reminder", bodyTemplate, true));
                        task.Start();

                        commisioningObj = context.tblCommissioning.Where(m => m.CommissioningId == obj.CommissioningId).FirstOrDefault();
                        commisioningObj.IsReadyForAMC = true;

                        context.Entry(commisioningObj).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Function to update entity.
 /// </summary>
 /// <param name="entity">entity to be updated</param>
 public string Update(T entity)
 {
     try
     {
         using (StandardEngEntities context = BaseContext.GetDbContext())
         {
             DbSet <T> table = context.Set <T>();
             table.Attach(entity);
             context.Entry(entity).State = EntityState.Modified;
             context.SaveChanges();
             return(string.Empty);
         }
     }
     catch (Exception ex)
     {
         return(CommonHelper.GetErrorMessage(ex));
     }
 }
예제 #5
0
        //public int SelectId(object pk)
        //{
        //    using (CosmosEntities context = BaseContext.GetDbContext())
        //    {
        //        return Convert.ToInt32(pk);
        //    }
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="pk">Primary key of entity to be deleted</param>
        public string Delete(object pk)
        {
            try
            {
                using (StandardEngEntities context = BaseContext.GetDbContext())
                {
                    DbSet <T> table    = context.Set <T>();
                    T         existing = table.Find(pk);
                    context.Entry(existing).State = EntityState.Deleted;
                    context.SaveChanges();

                    return(string.Empty);
                }
            }
            catch (Exception ex)
            {
                return(CommonHelper.GetDeleteException(ex));
            }
        }