Exemplo n.º 1
0
    public Model.SubPurchase AddSubpurchasePhone(string phone, Model.SubPurchase subpurchase)
    {
        if (subpurchase == null)
        {
            return(null);
        }

        //List<string> formatedPhones = GetPhoneFormatsList(phone);
        //foreach (string formatedPhone in formatedPhones)
        //{
        var newSubpurchasePhone = new Model.SubPurchasePhone()
        {
            Id = Guid.NewGuid(),
            //phone = formatedPhone,
            phone         = Phone.RemoveWrongSymbols(phone),
            createDate    = Utils.GetUkranianDateTimeNow(),
            SubPurchaseId = subpurchase.id
        };

        _context.SubPurchasePhones.InsertOnSubmit(newSubpurchasePhone);
        _context.SubmitChanges();
        //}

        return(subpurchase);
    }
Exemplo n.º 2
0
    public Model.SubPurchase AddSubpurchasePhone(string phone, string name, string surname, bool validated)
    {
        //string phoneLikeExpression = MakePhoneLikeExpression(phone);
        var selectPhone = _context.SubPurchasePhones
                          .FirstOrDefault(p => p.phone == phone);

        if (selectPhone == null)
        {
            var addingSubPurchase = new Model.SubPurchase()
            {
                id          = Guid.NewGuid(),
                name        = name,
                surname     = surname,
                not_checked = !validated,
                createDate  = Utils.GetUkranianDateTimeNow(),
                modifyDate  = Utils.GetUkranianDateTimeNow()
            };
            _context.SubPurchases.InsertOnSubmit(addingSubPurchase);
            _context.SubmitChanges();

            this.AddSubpurchasePhone(phone, addingSubPurchase);

            return(addingSubPurchase);
        }
        else
        {
            return(selectPhone.SubPurchase);
        }
    }
    public Model.SubPurchase AddSubpurchasePhone(string phone, Model.SubPurchase subpurchase)
    {
        if (subpurchase == null)
        {
            return(null);
        }

        var newSubpurchasePhone = new Model.SubPurchasePhone()
        {
            Id          = Guid.NewGuid(),
            phone       = phone,
            createDate  = Utils.GetUkranianDateTimeNow(),
            SubPurchase = subpurchase
        };

        _context.SubPurchasePhones.InsertOnSubmit(newSubpurchasePhone);
        _context.SubmitChanges();

        return(subpurchase);
    }
    protected void dlCheckSubPurchases_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        //--- save into DB
        var subpurchasesContext = new Model.DataModel();

        Label subpurchaseIdLabel;
        subpurchaseIdLabel = (Label)(e.Item.FindControl("subpurchaseId"));

        var editItemKey = Guid.Parse(subpurchaseIdLabel.Text);
        var subPurchase = new Model.SubPurchase()
        {
            id = editItemKey
        };
        subpurchasesContext.SubPurchases.Attach(subPurchase);

        subpurchasesContext.SubPurchases.DeleteOnSubmit(subPurchase);
        subpurchasesContext.SubmitChanges();
        //--- end save into DB

        dlCheckSubPurchases.EditItemIndex = -1;
        dlCheckSubPurchases.DataBind();
    }