Exemple #1
0
        public TagModel Save(TagModel TAG)
        {
            using (DBSHYMONEYV1Context context = new DBSHYMONEYV1Context())
            {
                TagModel tag = context.Tag.Where(x => x.Id == TAG.Id).FirstOrDefault();
                DateTime now = DateTime.Now;
                if (tag == null)
                {
                    tag = new TagModel()
                    {
                        Id            = TAG.Id,
                        Title         = TAG.Title,
                        Description   = TAG.Description,
                        Icon          = TAG.Icon,
                        QuickbarPlace = TAG.QuickbarPlace,
                        CreateDate    = now,
                        CreateBy      = tmpUserId,
                        ModifyDate    = now,
                        ModifyBy      = tmpUserId,
                        State         = "Y"
                    };
                    context.Tag.Add(tag);
                }
                else
                {
                    tag.Title         = TAG.Title;
                    tag.Description   = TAG.Description;
                    tag.Icon          = TAG.Icon;
                    tag.QuickbarPlace = TAG.QuickbarPlace;
                    tag.ModifyDate    = now;
                    tag.ModifyBy      = tmpUserId;
                }

                if (context.SaveChanges() >= 1)
                {
                    return(TAG);
                }
                else
                {
                    return(null);
                }
            }
        }
 public bool Delete(int ID)
 {
     using (DBSHYMONEYV1Context context = new DBSHYMONEYV1Context())
     {
         IntellisenseModel model = context.Intellisense.Where(x => x.Id == ID).FirstOrDefault();
         if (model != null)
         {
             DateTime now = DateTime.Now;
             model.ModifyBy   = tmpUserId;
             model.ModifyDate = now;
             model.State      = "N";
             context.SaveChanges();
             return(true);
         }
         else
         {
             throw new Exception("Record not found for deletion.");
         }
     }
 }
        public IntellisenseModel Save(IntellisenseModel input)
        {
            using (DBSHYMONEYV1Context context = new DBSHYMONEYV1Context())
            {
                IntellisenseModel model = context.Intellisense.Where(x => x.Id == input.Id).FirstOrDefault();
                DateTime          now   = DateTime.Now;
                if (model == null)
                {
                    model = new IntellisenseModel()
                    {
                        Title          = input.Title,
                        SumSum         = input.SumSum,
                        SumAccountDate = input.SumAccountDate,
                        SumInputDate   = input.SumInputDate,
                        SumDueDate     = input.SumDueDate,
                        CreateDate     = now,
                        CreateBy       = tmpUserId,
                        ModifyDate     = now,
                        ModifyBy       = tmpUserId,
                        State          = "Y"
                    };
                    context.Intellisense.Add(model);
                }
                else
                {
                    model.Title      = input.Title;
                    model.SumSum     = input.SumSum;
                    model.ModifyDate = now;
                    model.ModifyBy   = tmpUserId;
                }

                if (context.SaveChanges() >= 1)
                {
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #4
0
        public SumModel SaveGetSum(SumModel p_sum)
        {
            using (DBSHYMONEYV1Context context = new DBSHYMONEYV1Context())
            {
                SumModel sum = context.Sum.Where(x => x.Id == p_sum.Id).FirstOrDefault();
                DateTime now = DateTime.Now;
                if (sum == null)
                {
                    sum = new SumModel()
                    {
                        Title       = p_sum.Title,
                        Sum         = p_sum.Sum,
                        AccountDate = p_sum.AccountDate,
                        InputDate   = p_sum.InputDate,
                        DueDate     = p_sum.DueDate,
                        CreateDate  = now,
                        CreateBy    = tmpUserId,
                        ModifyDate  = now,
                        ModifyBy    = tmpUserId,
                        State       = "Y",
                        IsPayed     = "Y"
                    };
                    this.ResolveDateTypeDefaults(sum, p_sum);
                    context.Sum.Add(sum);
                }
                else
                {
                    List <SumTagConnModel> stcList = context.SumTagConn.Where(x => x.SumId == sum.Id).ToList();

                    sum.Title      = p_sum.Title;
                    sum.Sum        = p_sum.Sum;
                    sum.ModifyDate = now;
                    sum.ModifyBy   = tmpUserId;
                    this.ResolveDateTypeDefaults(sum, p_sum);

                    // remove old tag connections
                    if (stcList.Count > 0)
                    {
                        context.SumTagConn.RemoveRange(stcList);
                    }
                }

                // TODO Valamiért elrontja, ha vannak tagek
                // add tag connections
                if (p_sum.Tags != null)
                {
                    foreach (TagModel tag in p_sum.Tags)
                    {
                        context.SumTagConn.Add(new SumTagConnModel()
                        {
                            SumId = sum.Id,
                            TagId = tag.Id
                        });
                    }
                }

                if (context.SaveChanges() >= 1)
                {
                    return(sum);
                }
                else
                {
                    return(null);
                }
            }
        }